Bootstrap 3 Scrollspy Activate the event without crashing

I am trying to create a site using Bootstrap 3 RC1 with Scrollspy. My webpage is pretty straightforward right now and essentially created as follows:

<html>
    <head>
        <!-- Head stuff here -->
    </head>

    <body>
        <section id="section_1" data-spy="scroll">
            <!-- stuff in here -->
        </section>
        <section id="section_2" data-spy="scroll">
            <!-- stuff in here -->
        </section>
        <section id="section_3" data-spy="scroll">
            <!-- stuff in here -->
        </section>

        <JScripts here ... />
    </body>
</html>

I initialized Scrollspy by calling $("section").scrollspy(), and I configured the event handler as follows:

$("section").on("activate", function(e) {
    // do stuff
});

My problem is that this event activatenever fires. Does anyone know why it is not working? I noticed that all tutorials use the navigation bar to highlight the current section, but I really don't want a navigator.

+2
source share
1 answer

scrollspy . Scrollspy , , , . , scrollspy. , , .

body, .

<body data-spy="scroll" data-target="#YOUR NAV CONTAINER">

, , :

<div id="YOUR NAV CONTAINER">
     <ul class="nav">
          <li><a href="#SECTIONID">list item</a></li>
          <li><a href="#SECTIONID">list item2</a></li>
     </ul>
</div>
+5

All Articles