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

Sticky Header widget clones ID #271

Closed
ptepper opened this issue Mar 29, 2013 · 3 comments
Closed

Sticky Header widget clones ID #271

ptepper opened this issue Mar 29, 2013 · 3 comments
Labels

Comments

@ptepper
Copy link

ptepper commented Mar 29, 2013

I just noticed that the sticky header widget is creating two elements on the page with the same ID. I see you did this to maintain styling, but this is a problem in my case, as having two elements in the DOM with the same ID breaks other code. Is there any way around this, other than changing your code to make it assign a new ID when it clones the table?

@ptepper
Copy link
Author

ptepper commented Mar 29, 2013

For now I replaced your line in jquery.tablesorter.widget.js:

t2 = wo.$sticky = $table.clone(), // clone table, but don't remove id... the table might be styled by css

with this:

t2 = wo.$sticky = $table.clone().attr('id', $table.attr("id")+"Clone"),

I realize there is a compromise between keeping the user's style and not breaking the DOM but making them style the table with a class instead of by ID, but I don't think it makes sense to break the DOM in order to preserve styling by ID. In this case styling should be done by class and just documented in the widget docs. If you wanted to add more code you could move the styling for this ID into a class and apply it to both elements, but I don't think that's necessary.

Hope you don't mind the feedback, the code still works great :)

@Mottie
Copy link
Owner

Mottie commented Mar 29, 2013

HI @ptepper!

Yeah, that was a dilemma for me when writing the widget. I think at this point I'll just add an option that allows you to change the id of the clone.

Thanks!

@Mottie
Copy link
Owner

Mottie commented Apr 13, 2013

In verison 2.9.0, a new option was added to the sticky header widget named stickyHeaders_cloneId. It contains a string suffix to add to any table id. Default is -sticky.

Thanks for reporting this issue!

@Mottie Mottie closed this as completed Apr 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants