I read this question: How to use Twitter Bootstrap ScrollSpy to execute a function, that said to first grab the event, then to add a certain function. First, I’m relatively new to jQuery, so I don’t know how to grab an event.
Here is my code:
$(".navbar").scrollspy();
$('[data-spy="scroll"]').each(function()
{
$(this).scrollspy('refresh');
});
$("ul.nav li").on("activate", function()
{
console.log("ACTIVATED");
});
Triggering it manually runs the function, of course, but whatever I try to do, it doesn’t seem to work.
Any ideas?
Your code is correct, the latest (2.1.0) release of Bootstrap fixes the issue.
See https://github.com/twitter/bootstrap/issues/3316 and access the working script here: https://github.com/twitter/bootstrap/blob/2.1.0-wip/js/bootstrap-scrollspy.js.