- 主题:如何找到DOM结点上挂载着的事件处理函数
why you need it?
【 在 wuhaochi (oo) 的大作中提到: 】
: 比如$(table).find("tr").dblclick(function(event){...});
: 怎么样找回这个加进去的处理函数? 命名函数当然例外。我是指没有命名的。
: 而且如果$(table)也变成参数的话,那么命名函数也解决不了问题。
: ...................
--
FROM 218.241.172.*
$(table).dblclick(function() { whatever_to_do_with(this); })
【 在 wuhaochi (oo) 的大作中提到: 】
: 表行被移除到缓冲区
: 后再再移回来,需要这个事件重新绑定一下
--
FROM 218.241.172.*
if you mean to reuse the function, make it reusable. an inline function
expression is of course not reusable.
【 在 wuhaochi (oo) 的大作中提到: 】
: 这个……显然我会。我是问,现在,我给你一个$tr ,再给你一个$table,你能在$tr上绑上和$table中的表行一样的事件处理函数吗?注意$tr 并不一定来自于 $table。
--
FROM 218.241.172.*
【 在 wuhaochi (oo) 的大作中提到: 】
: 标 题: Re: 如何找到DOM结点上挂载着的事件处理函数
: 发信站: 水木社区 (Fri Jul 8 13:05:19 2016), 站内
:
: function rebind_event($tr, $table){
:
: // bind $table's row dblclick to $tr
:
: // how to implement this function ?
:
: }
:
:
: 【 在 XeCycle (据说是小 X) 的大作中提到: 】
: : if you mean to reuse the function, make it reusable. an inline function
s/the function/the handler function/
: : expression is of course not reusable.
:
:
: --
: 追逐生命的异彩!
:
:
: ※ 来源:·水木社区 newsmth.net·[FROM: 116.247.85.*]
--
FROM 218.241.172.*
function handler() {...}
// modify original code on $table
$table.find("tr").dblclick(handler);
// new code
$tr.dblclick(handler);
【 在 wuhaochi (oo) 的大作中提到: 】
: could you explain your idea more clear?
--
FROM 218.241.172.*
you don't know what handler is on the element? then that design is
absolutely broken.
but anyway, you are apparently asking an X-Y question.
【 在 wuhaochi (oo) 的大作中提到: 】
: 你这个是只针对一个$table,所以你知道这个$table的处理函数是handler
: 我上面已经给出了了函数声明,那就表示,这个$table是不确定的。自然不同的表对应不同的处理函数,所以我才有需要从$table里找处理函数。
: 你可以再理解一下我写那个函数声明的意图。
: ...................
--
FROM 218.241.172.*
lol so you do not want to fix a broken design but go with dirty hacks?
go ahead, I do not know the answer and am not at all interested. maybe
dig into jquery sources; anyway I'd bet no sane library/framework will
ever recommend that.
【 在 wuhaochi (oo) 的大作中提到: 】
: 显然不是
: 别扯什么设计不设计
: 不知道就不知道,这没啥啊。 但你说人家X-Y就装过头了。
: ...................
--
FROM 218.241.172.*