diff --git a/docs/assets/js/application.js b/docs/assets/js/application.js index 0252d75e96..84227f5557 100644 --- a/docs/assets/js/application.js +++ b/docs/assets/js/application.js @@ -119,7 +119,7 @@ $(function(){ // fix sub nav playa var $win = $(window) , $nav = $('.subnav') - , navTop = $('.subnav').offset().top - 40 + , navTop = $('.subnav').length && $('.subnav').offset().top - 40 , isFixed = 0 processScroll() diff --git a/docs/javascript.html b/docs/javascript.html index 425d347cb8..8cf95c8153 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -24,7 +24,7 @@ -
+ @@ -65,18 +65,18 @@Bring Bootstrap's components to life—now with 12 custom jQuery plugins.
diff --git a/js/bootstrap-scrollspy.js b/js/bootstrap-scrollspy.js index 5049bfdf95..91c49f32ee 100644 --- a/js/bootstrap-scrollspy.js +++ b/js/bootstrap-scrollspy.js @@ -26,10 +26,11 @@ function ScrollSpy( element, options) { var process = $.proxy(this.process, this) + , $element = $(element).is('body') ? $(window) : $(element) this.options = $.extend({}, $.fn.scrollspy.defaults, options) - this.$scrollElement = $(element).on('scroll.scroll.data-api', process) - this.selector = (this.$scrollElement.attr('data-target') - || this.$scrollElement.attr('href') + this.$scrollElement = $element.on('scroll.scroll.data-api', process) + this.selector = (this.options.target + || $(element).attr('href') || '') + ' .nav li > a' this.$body = $('body').on('click.scroll.data-api', this.selector, process) this.refresh() @@ -111,11 +112,13 @@ /* SCROLLSPY DATA-API - * ============== */ + * ================== */ $(function () { - var $spy = $('[data-spy="scroll"]') - $spy.scrollspy($spy.data()) + $('[data-spy="scroll"]').each(function () { + var $spy = $(this) + $spy.scrollspy($spy.data()) + }) }) }( window.jQuery ) \ No newline at end of file