CGridView jquery row selector problem (solved)

Hi

I have a <div id="parentView"> element containing a CGridView.

I bound the following delegated jquery event handler to this <div> element:

$(’#parentView’).on(“click”, “tr:gt(1)”, function(event){

//do something

});

This event handler catches the events bubbling up when the gridview’s rows are clicked.

My problem is that these row-clicked events are triggered – not only when the user clicks on a row, but also when the user clicks on a button in the row.

I thus have to change my code to only handle row-clicks that were not caused by the buttons on that row.

I suspect that the solution could be quite tricky if the button and its row fire separate events.

Any ideas?

Thanx

It looks like the following code did the trick:

$(’#parentView’).on(“click”, “table tbody td:not(td:.button-column)”, function(event){

The event no longer watch for row-clicking, but for <td> clicks. This allow you to filter out the button-column.

For those interested, there is a working example here:

http://www.yiiframework.com/wiki/323/dynamic-parent-and-child-cgridciew-on-single-view-using-ajax-to-update-child-gridview-via-controller-with-many_many-relation-after-row-in-parent-gridview-was-clicked/