-
Notifications
You must be signed in to change notification settings - Fork 67
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
ensure table of contents isn't created twice #35
Comments
A plugin library should not depend on the sequence of jquery document ready initializations. If custom code triggers the TOC.init() first, the library creates a DOM element that then results in duplication if your libraries' document ready is triggered. (In our case it's almost impossible to change this sequence..) The library is missing a protection against such a duplication. This can be achieved as simple as setting a helper class when completing init() that you then exclude in the libraries' document ready or the init() selector itself. |
Added a new PR for this #46. :) |
I land myself here after debugging this issue for hours. My case is a bit more complicated because I use AJAX to load documents and run |
With CSS, make sure you let
With Jquery and JS, make sure you let
And then TOC plugin will work perfectly. That is how I fixed it when TOC is duplicated. |
And if above solution does not work, you can try to use JS to remove one of two duplicated TOCs.
|
I tried, and out of frustration I modified |
When my TOC plugin created two Table of contents instead of one, I checked the .html source in browser's developer mode and I see that it created two And I mean, you should add this script to a |
Multiple people have run into the issue (#21 and #34), so either the instructions aren't clear enough, or the plugin should Do the Right Thing and not initialize multiple times.
The text was updated successfully, but these errors were encountered: