]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
allow scrollspy to target a specific nav
authorJacob Thornton <jacobthornton@gmail.com>
Sat, 26 Nov 2011 01:30:52 +0000 (17:30 -0800)
committerJacob Thornton <jacobthornton@gmail.com>
Sat, 26 Nov 2011 01:30:52 +0000 (17:30 -0800)
docs/javascript.html
js/bootstrap-scrollspy.js

index fae1038566c62a5f35832bb0a7312d7f336ea79b..3e2bacc9d43ea3760abdb10a15252bf80e221e98 100644 (file)
@@ -380,7 +380,7 @@ $('#myModal').bind('hidden', function () {
             Scroll the area below and watch the navigation update. The dropdown sub items will be highlighted as well. Try it!</p>
           <p>
 
-          <div id="navbar-example" class="navbar navbar-static">
+          <div id="navbarExample" class="navbar navbar-static">
             <div class="navbar-inner">
               <div class="container" style="width: auto;">
                 <a class="brand" href="#">Project Name</a>
@@ -401,7 +401,7 @@ $('#myModal').bind('hidden', function () {
             </div>
           </div>
 
-          <div data-spy="scroll" class="scrollspy-example">
+          <div data-spy="scroll" data-target="#navbarExample" class="scrollspy-example">
             <h4 id="fat">@fat</h4>
             <p>
             Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
index ac9477d0ef9d97fa128ed0aefeb09b4683fb55e0..e4bfea4836f7911c249788f92d32108d3be24b56 100644 (file)
 
   function ScrollSpy( element ) {
     var process = $.proxy(this.process, this)
-    this.selector = '.nav li > a'
 
-    this.$body = $('body').delegate(this.selector, 'click.scroll.data-api', process)
     this.$scrollElement = $(element).bind('scroll.scroll.data-api', process)
+    this.selector = (this.$scrollElement.attr('data-target') || '') + ' .nav li > a'
+    this.$body = $('body').delegate(this.selector, 'click.scroll.data-api', process)
 
     this.refresh()
     this.process()