-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trigger("update") causes table contents to be deleted #217
Comments
Hi @adamthehutt! Maybe this demo will help clarify any issues you might be having? $('.remove').click(function(){
$(this).closest('tr').remove();
$('table').trigger('update');
}); If you are using the pager plugin as well, then I would suggest making sure the pager |
Thanks, Mottie. That helped me debug the issue. Turns out the problem is that my site also includes the Prototype library, so I'm using jQuery.noconflict() to assign the $() function a different name. When I remove Prototype, everything works correctly. So, my guess is that something in the tablesorter plugin isn't wrapped in a way that accommodates noconflict(). What's weird is that tablesorter otherwise works perfectly. It's just when I trigger an update that it breaks. Any ideas? Thanks again for your help. |
UPDATE: I found this discussion on StackOverflow: Looks like the problem is actually with Prototype, not Tablesorter. |
Hmm, maybe I should add another trigger along with "update", something like "tsUpdate"? Normally, I would namespace the event ( Anyway, for a quick fix, update line 706 from this: .bind("update", function(e, resort, callback) { to this: .bind("update tsUpdate", function(e, resort, callback) { then just use: $('table').trigger('tsUpdate'); |
Thanks. That would work, although I'm trying to avoid making changes that will be reverted if I upgrade to a newer version of Tablesorter in the future. (My problem, not yours... I think I have another, cruder workaround in the meantime.) I like the idea of creating an alias trigger for future versions. Maybe you could use "updateContents" or "updateRows" for consistency (since the other events aren't namespaced). Just a suggestion (admittedly an anal one). |
Hmm, I do like "updateRows" better. I'll add it in the next update! :) |
That sounds great! Thanks for being so responsive. I'll go ahead and modify my local copy of the tablesorter plugin to use updateRows in the meantime. |
As soon as I figure out how to register a plugin "correctly" with the jquery plugin registry, I'll push the update. |
Hi,
I'm using the latest version of tablesorter. After deleting a row from a table, I'm calling $("table").trigger("update"). Every time I call that, however, the entire contents of the table are deleted, leaving only the opening and closing
tags.What's even stranger is that the same thing happens when I call trigger("update") even without removing any rows (i.e. immediately after initializing the tablesorter).
I've been banging my head against this wall for a while. Probably I'm doing something stupid, but any insights would be greatly appreciated.
Thanks,
Adam
The text was updated successfully, but these errors were encountered: