Image swaping with click on <tr>
- by Jonny Sooter
I've edited this piece of code from the Data Tables Plugin witch makes a tr click able and pops open another tr with details from the clicked tr. This piece of code is the event listener for opening and closing. When "details" are open the img should be images/details_close.png and they are closed the img should be images/details_open.png and have a swap occurring when it opens and closes when clicked. What is happening is there is no swap going on when its open or closed I still only get the "details_open.png". I don't knoe if I'm just not selecting the img tag properly or whats going on.
Link to project:
http://www2.kent.k12.wa.us/ksd/it/www/mobile/elementary.html
$('#example tbody').on('click', 'td', function (e) {
var myImage = $(this).find("img");
var nTr = $(this).parents('tr')[0];
if ( oTable.fnIsOpen(nTr) )
{
/* This row is already open - close it */
myImage.src = "images/details_open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
myImage.src = "images/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}
} );