Can delegate work instead of click for detail row?

Can delegate work instead of click for detail row?

MikeSMikeS Posts: 113Questions: 1Answers: 0
edited August 2010 in General
Hi all,

I'm using this plugin with a table that can exceed 700 rows. Each row has a detailed row that is shown/hidden using the following code taken from the samples area:

[code]
$('td img', oTable.fnGetNodes()).each( function () {
$(this).click( function (event) {

var nTr = this.parentNode.parentNode;
if ( this.src.match('details_close') )
{
/* This row is already open - close it */
this.src = "./Images/details_open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "./Images/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
}
} );
} );
[/code]

This code works fine, except that I think that it could be made faster by using a delegate rather than hooking up individual click events to each and every row. I'm thinking that a delegate attached to the TBODY and targeting the TR should do. Being the jQuery noob that I am, I was wondering if:

1) I am correct ? and more importantly,
2) can anyone change the code to implement it ?

All feedback is greatly appreciated.

Replies

  • MikeSMikeS Posts: 113Questions: 1Answers: 0
    Never mind...I stumbled thru and it works, although it does not *seem* to be any faster :(
This discussion has been closed.