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

Wrong behavior when stupid_table is inside an other table (bug) #170

Open
wisedevman opened this issue Oct 22, 2016 · 3 comments
Open

Wrong behavior when stupid_table is inside an other table (bug) #170

wisedevman opened this issue Oct 22, 2016 · 3 comments

Comments

@wisedevman
Copy link

Hi,
very useful and light script.

I think I've found a bug when a stupid table is inside an other table. Sorting by other columns except the first fails.

The bug is where the code compute th_index, because parents() get the outer tr (of the outer table).

I fixed it in this way:

    // Account for colspans
$this_th.parents("tr").find("th").slice(0, $(this).index()).each(function() {

should read

    // Account for colspans
$this_th.parent("tr").find("th").slice(0, $(this).index()).each(function() {

If you agree please update the repo, thank you.

@svivian
Copy link
Collaborator

svivian commented Oct 25, 2016

Is <tr> always a parent of <th> ? I don't remember whether it's valid to have another element in between.

Either way, another solution would be to use .closest("tr") so that we only select the first <tr> we come to.

@joequery
Copy link
Owner

Is stupidtable being called on the outer table or the inner table in your example here? Would you happen to have a testcase demonstrating the issue?

@wisedevman
Copy link
Author

Sorry for the late in the answer.
It's called on the inner table.
Sorry but I don't have a quick test case to show.

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

3 participants