Valentin Despa
Valentin Despa

Reputation: 42582

Bootstrap - Affix & scrollspy - active on scroll not working

I have the following jsfiddle

I can't get the:

I am stuck on this. Anybody willing to enlighten me what I did wrong?

Upvotes: 1

Views: 10980

Answers (2)

David Taiaroa
David Taiaroa

Reputation: 25483

Picking up on the heavy lifting by @Skelly, here's a variation: http://jsfiddle.net/panchroma/TcyBY/

I've moved the scrollspy call out of the body tag to a separate js

$('body').scrollspy({ target: '.sidebar-nav' }); 

The documentation on the Bootstrap site for scrollspy could probably be clearer. Here's a link which might help explain some of the blips: http://mtjhax.wordpress.com/2013/02/11/twitter-bootstraps-scrollspy-plugin-needs-better-docs/

Hope this helps!

Upvotes: 3

Carol Skelly
Carol Skelly

Reputation: 362430

You need to add 'scrollspy' to the body tag in order for it to activate the menu items.

<body data-spy="scroll" data-target=".navspy">

http://jsfiddle.net/skelly/yPgUu/253/

Upvotes: 5

Related Questions