Tablesorter bug cloning table row with jquery -
i'm trying wrap head around why rows being duplicated once removed when tablesorter function being used. here page in question:
http://www.ffxiv-gathering.com/40.php
to duplicate bug following:
- click row on unspoiled tab
- go watching tab
- click row remove it
- go unspoiled tab , click row...then click another
- go watching tab
you can see first row clicked duplicated. cannot life of me figure out why. removing tablesorter function fixes problem...however, remain sorts table status (and moves current , upcoming nodes top).
here jquery running this:
$(document).ready(function() { var items = []; $("#mytable-unspoiled >tbody >tr").on("click", function() { var newtr = $(this).closest("tr").clone().addclass("remove"); items.push(newtr); newtr.appendto($("#mytable-watching")); $(".remove").click(function(){ $(this).closest('tr').remove(); var rowcount = $('#mytable-watching >tbody >tr').length; $('#counter').html(rowcount); }); var rowcount = $('#mytable-watching >tbody >tr').length; $('#counter').html(rowcount); $("#mytable-watching").tablesorter({ // sort status column, item; ascending sortlist: [[6,0],[0,0]] }); }); });
removing fixes problem prevents me sorting:
$("#mytable-watching").tablesorter({ // sort status column, item; ascending sortlist: [[6,0],[0,0]] });
here page without tablesorter plugin.
http://www.ffxiv-gathering.com/40-test.php
to see issue...click colored row, white row, colored row , view watching tab.
when add and/or remove rows table, make sure trigger "update" instead of reinitializing tablesorter...
newtr.appendto($("#mytable-watching")); $("#mytable-watching").trigger("update");
and
$(".remove").click(function(){ var $table = $(this).closest('table'); $(this).closest('tr').remove(); $table.trigger('update'); // ... });
Comments
Post a Comment