From bc07e2adae7bc61795d54681915d791aee41c49a Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 18 Apr 2012 13:35:14 -0700 Subject: allow for pushstate in scrollspy --- js/bootstrap-scrollspy.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/bootstrap-scrollspy.js b/js/bootstrap-scrollspy.js index c67f1c8aa..5c19ae382 100644 --- a/js/bootstrap-scrollspy.js +++ b/js/bootstrap-scrollspy.js @@ -54,7 +54,8 @@ $targets = this.$body .find(this.selector) .map(function () { - var href = $(this).attr('href') + var $el = $(this) + , href = $el.data('target') || $el.attr('href') , $href = /^#\w/.test(href) && $(href) return ( $href && href.length @@ -91,6 +92,7 @@ , activate: function (target) { var active + , selector this.activeTarget = target @@ -98,7 +100,11 @@ .parent('.active') .removeClass('active') - active = $(this.selector + '[href="' + target + '"]') + selector = this.selector + + '[data-target="' + target + '"],' + + this.selector + '[href="' + target + '"]' + + active = $(selector) .parent('li') .addClass('active') -- cgit v1.2.3