0

我在下拉列表中有这个目录,我想用它scrollspy()来跟踪我在文档中的位置。我经常有数百页,所以overflow-y: auto;在这一点上进行下拉并具有一定的设计意义。但是,当页面更改时,我还想做一些其他的事情。值得注意的是,将下拉按钮上的 Page # 更改为实际页面。根据文档,我将使用以下内容:

$('#myScrollspy').on('activate.bs.scrollspy', function () {
  // do something…
})

但是,这不起作用。请参阅以下小提琴: http: //jsfiddle.net/Mt25g/ 注意:我正在使用引导程序 3.0.2 并尝试激活而不是 activate.bs.scrollspy - 出于某种原因。这就是它“使用”的方式。

我已经粘贴了下面的代码。我计划在他们的 github 页面上打开一个问题,但由于我对使用引导程序相当陌生,我想我会先寻求帮助。可能我做错了什么?(代码如下)

HTML

<nav class="navbar navbar-inverse navbar-fixed-top" id="nav_container" role="navigation">
    <div class="container">
        <a class="navbar-brand" href="#">Some WorkSpace</a>

        <div class="pull-right nav">
            <div class="btn-group">
                <button type="button" class="btn btn-primary navbar-btn">«</button>
                <button type="button" class="btn navbar-btn btn-primary dropdown-toggle" data-toggle="dropdown" id="page_nav">Page: # <span class="caret"></span>
                </button>


<ul class="dropdown-menu" id="page_nav" aria-labelledby="dLbael">


    <li role="presentation" class="pg_nav">
        <a href="#pg-1" title="Page : no page number" role="menuitem" tabindex="-1">1</a>
    </li>
     <li role="presentation" class="pg_nav">
        <a href="#pg-2" title="Page : no page number" role="menuitem" tabindex="-1">2</a>
    </li>
     <li role="presentation" class="pg_nav">
        <a href="#pg-3" title="Page : no page number" role="menuitem" tabindex="-1">3</a>
    </li>




</ul>
                <button type="button" class="btn btn-primary navbar-btn">»</button>
            </div>
            <button type="button" class="btn navbar-btn" disabled="disabled">
                Apply
            </button>
            <button type="button" class="btn btn-warning navbar-btn">
                Reset
            </button>
        </div>
    </div>
</nav>
<div class="container">
    <section id="pg-1">
        <h3>Bacon</h3>
        <p>
        Bacon ipsum dolor sit amet strip steak boudin shankle jerky meatball corned beef, kielbasa hamburger pastrami prosciutto. Frankfurter andouille jowl prosciutto leberkas brisket t-bone. Tri-tip pancetta cow pastrami pig beef ribs short ribs pork belly ham hock tenderloin turkey andouille. Sausage shoulder strip steak jowl tongue chuck, frankfurter ball tip beef ribs brisket. Spare ribs frankfurter beef ribs pig flank. Pancetta ball tip t-bone spare ribs brisket. Venison ham short ribs tenderloin, meatloaf biltong doner prosciutto pork leberkas pork chop shank tail chuck.
        </p>
        <p>
Pastrami sausage filet mignon leberkas pork bresaola shank corned beef sirloin. Ham hock salami jerky strip steak capicola sirloin venison filet mignon boudin. Sirloin meatball kielbasa pig, drumstick beef ribs tenderloin shank prosciutto corned beef. Ham hock shankle capicola, sausage meatball strip steak ribeye kielbasa.
        </p>
        <p>
Pancetta capicola sirloin, biltong pork loin chuck turducken boudin. Shoulder hamburger andouille pork loin pork belly chicken. Venison ball tip ground round meatloaf rump cow biltong kielbasa tail capicola flank. Tongue andouille strip steak, venison pork belly ham boudin jowl shank capicola pig shankle. Bacon pastrami pancetta, sausage hamburger chicken shank short loin. Swine fatback short loin, ham filet mignon t-bone turkey jowl prosciutto.
        </p>
    </section>
        <section id="pg-2">
        <h3>Sausage</h3>
        <p>
        Bacon ipsum dolor sit amet strip steak boudin shankle jerky meatball corned beef, kielbasa hamburger pastrami prosciutto. Frankfurter andouille jowl prosciutto leberkas brisket t-bone. Tri-tip pancetta cow pastrami pig beef ribs short ribs pork belly ham hock tenderloin turkey andouille. Sausage shoulder strip steak jowl tongue chuck, frankfurter ball tip beef ribs brisket. Spare ribs frankfurter beef ribs pig flank. Pancetta ball tip t-bone spare ribs brisket. Venison ham short ribs tenderloin, meatloaf biltong doner prosciutto pork leberkas pork chop shank tail chuck.
        </p>
        <p>
Pastrami sausage filet mignon leberkas pork bresaola shank corned beef sirloin. Ham hock salami jerky strip steak capicola sirloin venison filet mignon boudin. Sirloin meatball kielbasa pig, drumstick beef ribs tenderloin shank prosciutto corned beef. Ham hock shankle capicola, sausage meatball strip steak ribeye kielbasa.
        </p>
        <p>
Pancetta capicola sirloin, biltong pork loin chuck turducken boudin. Shoulder hamburger andouille pork loin pork belly chicken. Venison ball tip ground round meatloaf rump cow biltong kielbasa tail capicola flank. Tongue andouille strip steak, venison pork belly ham boudin jowl shank capicola pig shankle. Bacon pastrami pancetta, sausage hamburger chicken shank short loin. Swine fatback short loin, ham filet mignon t-bone turkey jowl prosciutto.
        </p>
    </section>
        <section id="pg-3">
        <h3>"Right Lisa"
            <small>Some Magical Animal</small></h3>
        <p>
        Bacon ipsum dolor sit amet strip steak boudin shankle jerky meatball corned beef, kielbasa hamburger pastrami prosciutto. Frankfurter andouille jowl prosciutto leberkas brisket t-bone. Tri-tip pancetta cow pastrami pig beef ribs short ribs pork belly ham hock tenderloin turkey andouille. Sausage shoulder strip steak jowl tongue chuck, frankfurter ball tip beef ribs brisket. Spare ribs frankfurter beef ribs pig flank. Pancetta ball tip t-bone spare ribs brisket. Venison ham short ribs tenderloin, meatloaf biltong doner prosciutto pork leberkas pork chop shank tail chuck.
        </p>
        <p>
Pastrami sausage filet mignon leberkas pork bresaola shank corned beef sirloin. Ham hock salami jerky strip steak capicola sirloin venison filet mignon boudin. Sirloin meatball kielbasa pig, drumstick beef ribs tenderloin shank prosciutto corned beef. Ham hock shankle capicola, sausage meatball strip steak ribeye kielbasa.
        </p>
        <p>
Pancetta capicola sirloin, biltong pork loin chuck turducken boudin. Shoulder hamburger andouille pork loin pork belly chicken. Venison ball tip ground round meatloaf rump cow biltong kielbasa tail capicola flank. Tongue andouille strip steak, venison pork belly ham boudin jowl shank capicola pig shankle. Bacon pastrami pancetta, sausage hamburger chicken shank short loin. Swine fatback short loin, ham filet mignon t-bone turkey jowl prosciutto.
        </p>
    </section>

</div>

JAVASCRIPT

$(function() { 
    $('body').scrollspy({target: '#nav_container', offset: 47}); 
    $('#nav_container').on('activate.bs.scrollspy', function() { 
        console.log('sparkle, sparkle');
    });
});

CSS

section { padding-top: 40px; }

4

1 回答 1

0

'doh

<li>没有下拉类。

于 2013-11-14T16:02:54.983 回答