tags:

views:

2106

answers:

3

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

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.

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.

Thanks!

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

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

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

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

Something else is going on here.

Marc
Oh boy, duh! The other onclick events are on the table cell and my new events are on the anchor within the cell. Just noticed that now.
mattmac
+2  A: 

Use the jqGrid onCellSelect event. jqGrid Docs

Jataro
A: 

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...

happytime harry