1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-08 22:56:46 +02:00

scrollspy working for sub navs

This commit is contained in:
Jacob Thornton
2012-01-24 22:33:33 -08:00
parent f2fe2b1798
commit 5e5e87fbd0
3 changed files with 23 additions and 20 deletions

View File

@@ -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 )