Using jQuery Objects with rows().remove() removes all rows.

Using jQuery Objects with rows().remove() removes all rows.

DalderDalder Posts: 30Questions: 12Answers: 1

Hello again!

Another day another issue :smiley:

I'm trying to delete certain rows from my table using selected jQuery objects.

Here is a link to my example: http://live.datatables.net/jeneyera/1/

As you can see I am calling rowsToDelete = $(".eventRow:eq(0)"); which should be removing only the first row in the table, but it actually removes everything.

If you look in the console I'm outputting the jQuery object and it is definitely only returning a single row, meaning something is going wrong with the remove() itself.

Any ideas?

Thanks,

Dan

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,211Questions: 1Answers: 10,205 Site admin
    Answer ✓

    Hi Dan,

    The remove() method doesn't accept any parameters as the rows().remove() documentation shows.

    Use the rows() method to select the rows you want to perform an action on and then call that action method.

    http://live.datatables.net/jeneyera/2/edit

    Allan

  • DalderDalder Posts: 30Questions: 12Answers: 1

    Hi Allan,

    Looks like I just put the parameter in the wrong method.

    Silly me, thanks for letting me know.

This discussion has been closed.