Datatables always deletes first row

Datatables always deletes first row

crasxcrasx Posts: 3Questions: 0Answers: 0
edited December 2010 in General
Hi, I absolutely love datatables and you seem to have great support here.

I am using datatables with jquery's draggable and droppable ui plugins and have the following code:
[code]

$( ".topContestant" ).droppable({
drop: function( event, ui ) {
var parent=ui.draggable.closest("tr");

console.log( $($(criteriaSortedTable.fnGetNodes()).filter("#"+parent.attr('id'))[0]).html() );
criteriaSortedTable.fnDeleteRow($($(criteriaSortedTable.fnGetNodes()).filter("#"+parent.attr('id')[0])));
$(this).html( ui.draggable.html() );
//parent.remove();
}


});
});



[/code]

at console.log it outputs the correct row's html I want to delete, but at fndeleterow it deletes row 0. I have tried multiple variations like just passing parent and just using .filter() without array index 0 but it always deletes the first row. Am I doing something wrong?

Thanks
crasx

Replies

  • allanallan Posts: 63,510Questions: 1Answers: 10,471 Site admin
    You are passing fnDeleteRow a jQuery object rather than a DOM node. Just stick a [0] on the end of the $($(..)) bit and that should work okay.

    Future versions of the DataTables API will support this, but probably not until the next major version.

    Allan
  • crasxcrasx Posts: 3Questions: 0Answers: 0
    Ohh ok that makes sense!

    Thanks a lot
This discussion has been closed.