gfranko / jquery.tocify.js

A jQuery Table of Contents plugin that can be themed with Twitter Bootstrap or jQueryUI.
http://gregfranko.com/jquery.tocify.js/
MIT License
927 stars 217 forks source link

Wordpress page title causes error in tocify #60

Closed tgelles closed 10 years ago

tgelles commented 10 years ago

I'm using tocify with Wordpress, and noticed that the page title that Wordpress renders is causing a bug with the TOC.

In order for the other headings to get rendered and displayed properly, I need to add another H1 to the top of the page...which isn't really ideal. If I don't add a second h1 tag, only the page title will display in the table of contents.

Has anyone else encountered this and/or have a workaround?

For what it's worth I'm using the Roots theme.

gfranko commented 10 years ago

The page title definitely shouldn't be affecting the TOC. Do you have a public URL I could look at?

tgelles commented 10 years ago

Sure!

Here's a page that I added a second, hidden h1 tag: http://devng.sdss.org/test/

And here's a page that does not have a second h1 tag: http://devng.sdss.org/test2/

gfranko commented 10 years ago

The reason this isn't working is because none of your other headers are sibling DOM elements to your initial h1 (you have wrapped it in a separate page header div).

This is related to the content algorithm that Tocify uses to generate the TOC (referenced in #46 ). If you change the <h1>test</h1> from being a header, it should work as you expect.