From 5e5e87fbd0f577256d8a2b479bb9ed2187ff7f91 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Tue, 24 Jan 2012 22:33:33 -0800 Subject: scrollspy working for sub navs --- js/bootstrap-scrollspy.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'js') diff --git a/js/bootstrap-scrollspy.js b/js/bootstrap-scrollspy.js index 5049bfdf9..91c49f32e 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 -- cgit v1.2.3