jQuery获取元素的当前click事件并追加到它

时间:2021-01-09 21:04:50

I'm using jqGrid and adding my own onclick event to each cell of data when the grid has completed rendering.

当网格完成渲染时,我正在使用jqGrid并将自己的onclick事件添加到每个数据单元格。

jqGrid has default behavior of highlighting a row onclick. When I add my own onclick event after the grid renders, my event overwrites the jqGrid event as expected. I would like to preserve the jqGrid onclick event and just add my event to it.

jqGrid具有突出显示行onclick的默认行为。当我在网格渲染后添加自己的onclick事件时,我的事件会按预期覆盖jqGrid事件。我想保留jqGrid onclick事件,只需添加我的事件即可。

How can I get the current onclick event for all elements matching a certain class and just append more actions to the event? This is my current new onclick event.

如何获取与特定类匹配的所有元素的当前onclick事件,并为事件添加更多操作?这是我目前的新onclick事件。

Thanks!

$(".searchOrders").click(function() {
    $('#tabs').tabs('url', 2, '/view/dspOrders.cfm?id_orders='+$(this).attr('title'));
    $('#tabs').tabs('select', 2);
});

3 个解决方案

#1


3  

The jQuery event binding mechanism isn't one that overwrites. In other words:

jQuery事件绑定机制不是覆盖的机制。换一种说法:

 $("#button").click(function() { alert("hello"); });
 $("#button").click(function() { alert("goodbye"); });

has two events fired on #button, the second one doesn't overwrite the first.

在#button上触发了两个事件,第二个事件没有覆盖第一个事件。

Something else is going on here.

还有其他事情发生在这里。

#2


3  

Use the jqGrid onCellSelect event. jqGrid Docs

使用jqGrid onCellSelect事件。 jqGrid文档

#3


0  

you can adapt some code i use to insert a load event:

您可以调整我用于插入加载事件的一些代码:

// stack the original loads
var aryLoadQueue = new Array();
$.each($.data($main.get(0), "events").load, function() {
    aryLoadQueue.push(this);
});

...

// put the original loads back in place to take place after our one-time load
$(aryLoadQueue).each(function() {
    $main.load(this);
});

feel free to comment with questions...

随时提出问题评论......

#1


3  

The jQuery event binding mechanism isn't one that overwrites. In other words:

jQuery事件绑定机制不是覆盖的机制。换一种说法:

 $("#button").click(function() { alert("hello"); });
 $("#button").click(function() { alert("goodbye"); });

has two events fired on #button, the second one doesn't overwrite the first.

在#button上触发了两个事件,第二个事件没有覆盖第一个事件。

Something else is going on here.

还有其他事情发生在这里。

#2


3  

Use the jqGrid onCellSelect event. jqGrid Docs

使用jqGrid onCellSelect事件。 jqGrid文档

#3


0  

you can adapt some code i use to insert a load event:

您可以调整我用于插入加载事件的一些代码:

// stack the original loads
var aryLoadQueue = new Array();
$.each($.data($main.get(0), "events").load, function() {
    aryLoadQueue.push(this);
});

...

// put the original loads back in place to take place after our one-time load
$(aryLoadQueue).each(function() {
    $main.load(this);
});

feel free to comment with questions...

随时提出问题评论......