remove() makes variable undefined?
remove() makes variable undefined?
hanmumu
Posts: 5Questions: 2Answers: 0
Hello, everyone!
I've been at this for a day. I'm trying to remove rows with a certain data attribute, but there's always a few rows that are left behind
Now I narrowed it down to the .remove().draw() method itself! How weird is that?! But sure enough, if I add the .remove().draw(), all the alerts past a certain point turn null or undefined
var table = $j('#table_view_subs').DataTable();
table.rows().eq(0).filter( function (index) {
var row = table.row( index );
var rowdata = row.data();
alert(rowdata); //suddenly returns undefined
var data = row.nodes().to$().data();
alert(JSON.stringify(data)); //suddenly returns null
var closesttr = table.row( $(this).closest("tr").get(0) );
closesttr.remove().draw(); //if I comment this, all the alerts show the right info
});
Have you ever seen this before? What can I be doing wrong?
This discussion has been closed.
Answers
Hi @hanmumu ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hey @colin,
Thanks for the tip!
This is the code that I'm using: http://live.datatables.net/roxuneza/1/edit?html,js,console,output
I'm getting some strange errors in the console. I don't know how to interpret them, tho But this is the code I'm using and it runs! I just doesn't work
Ended up using this:
Hope it helps someone!