Skip to content
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

reloading table #199

Closed
argrithmag opened this issue Dec 18, 2012 · 3 comments
Closed

reloading table #199

argrithmag opened this issue Dec 18, 2012 · 3 comments

Comments

@argrithmag
Copy link

Okay, I admit, i'm doing some crazy stuff with my page. However, this is what's happening.

I have a table on a tab, that I load some data into via an ajax call. I take all the json, build the body, and load it into the table.

if the user changes tabs, then returns to the initial one, I remove all the TRs and reload the table.

What i'm seeing is that the initial sorting works find from the empty table. However, when i remove the rows and reload the data and perform the initial default sort on it, I get an error in the JS:

Uncaught TypeError: Cannot read property '0' of undefined jquery.tablesorter.js:239

This is the line it pukes on:
v = parsers[j].format(t, table, c[0].cells[j], j);

thoughts? I'll try to build a working example

@Mottie
Copy link
Owner

Mottie commented Dec 19, 2012

It sounds like maybe you're removing the TRs in the head? Because the parsers variable shouldn't be undefined.

In the next update, I'll add a check to prevent that error, but I'd need to see the code to tell you what's going on.

@argrithmag
Copy link
Author

I think i might have figured it out. I was loading the rows via append all at once, and they were wrapped in a tag. however, when i was clearing them out, I only cleared out the so i ended up with multiple tags in the table, one empty the second with the rows. never a good thing ;)

@Mottie
Copy link
Owner

Mottie commented Dec 19, 2012

Did you know there is a built-in function to clear the tbody?

$.tablesorter.clearTableBody( table );

It will clear all tbodies that don't have the cssInfoBlock class name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants