Can't delete rows created with fnAddData()
Can't delete rows created with fnAddData()
That's correct. I can delete rows hardwired in HTML, but not when the rows have been added with fnAddData(). I've checked everything but to no avail. Please someone help; I don't want to give up on this extraordinary piece of code and go back to run-of-the-mill Javascript. Thanks in advance!
This discussion has been closed.
Replies
Allan
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
var oTable;
var giRedraw = false;
$(document).ready(function() {
/* Add a click handler to the rows - this could be used as a callback */
$("#example tr").click(function(event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
});
/* Add a click handler for the delete row */
$('#delete').click( function() {
var anSelected = fnGetSelected( oTable );
oTable.fnDeleteRow( anSelected[0] );
} );
/* Init the table */
oTable = $('#example').dataTable( );
} );
/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i
Here is a working example with live events: http://live.datatables.net/aruwat/2/edit .
Also Visual Event might be of use to you in future for similar issues as it will show you want elements have events and which don't: http://www.sprymedia.co.uk/article/Visual+Event+2
Allan
Thanks a lot again!!
Allan