如果像我标题里要求的,能直接从所给的DOM节点得到它上面挂截的 event handler,那么在给节点挂handler时就无所谓给不给名字。比如,假设jquery提示 jquery.get_handler('dblclick')这样的函数
那么我只需要这么做。 $table.dblclick(function (){
// this is anonymous function, but we can find it by $.get_handler
})
now:
function rebind($tr, $table){
$tr.dblclick($table.get_handler('dblclick'));
}
这,不就是不需要naming了吗
我想没有提供这样的函数,大概是因为DOM结点上的事件处理器有多个,而且根据DOM的事件处理机制,可能对用户也并没有卵用,用户无法区分哪个才是自己需要的。
但你之前提到的 triggerhandler()这个就对了。因为我的需求的确就“应该”是“按照用户双击事件那样做出反应”, 虽然这个“应该”我自己都没意识到。
【 在 ottffsse (nothing) 的大作中提到: 】
: 标 题: Re: 如何找到DOM结点上挂载着的事件处理函数
: 发信站: 水木社区 (Sat Jul 9 11:09:34 2016), 站内
:
: the whole point is "referenceable", be it from your "map" or naming.
: In this sense, they are common.
:
: But yours is dynamic (the reference of reference)
: 【 在 wuhaochi (oo) 的大作中提到: 】
: : 但是这样就有一个 table => function的map了。
: : 可以从参数table里直接找到对应的function。如果只是naming。不太好办吧。
: : 以便我再次表达不清楚。举一个例子
: : ...................
:
: --
:
: ※ 来源:·水木社区
http://newsmth.net·[FROM: 183.95.135.*]
--
FROM 116.247.85.*