aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Thornton <[email protected]>2011-11-25 17:30:52 -0800
committerJacob Thornton <[email protected]>2011-11-25 17:30:52 -0800
commitbd8745a98b93fb55e4c1c08a34e97bd30a16798c (patch)
treeb173d55f30d5c8d60018fe6f2eb28380a1928459
parent98fddaa3557b1c872f1e585d579ec7e5e989e95d (diff)
downloadbootstrap-bd8745a98b93fb55e4c1c08a34e97bd30a16798c.tar.xz
bootstrap-bd8745a98b93fb55e4c1c08a34e97bd30a16798c.zip
allow scrollspy to target a specific nav
-rw-r--r--docs/javascript.html4
-rw-r--r--js/bootstrap-scrollspy.js4
2 files changed, 4 insertions, 4 deletions
diff --git a/docs/javascript.html b/docs/javascript.html
index fae103856..3e2bacc9d 100644
--- a/docs/javascript.html
+++ b/docs/javascript.html
@@ -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.
diff --git a/js/bootstrap-scrollspy.js b/js/bootstrap-scrollspy.js
index ac9477d0e..e4bfea483 100644
--- a/js/bootstrap-scrollspy.js
+++ b/js/bootstrap-scrollspy.js
@@ -26,10 +26,10 @@
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()