diff options
| author | Jacob Thornton <[email protected]> | 2011-10-04 22:11:44 -0700 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2011-10-04 22:11:44 -0700 |
| commit | a2c263493a7b6ca1933778feada80bab38c78581 (patch) | |
| tree | dc3f470cbea0b80a07fe653463bf3f97bc650bf7 /js | |
| parent | 100954eeda40a5003ed14b41a031b77575afb8cb (diff) | |
| download | bootstrap-a2c263493a7b6ca1933778feada80bab38c78581.tar.xz bootstrap-a2c263493a7b6ca1933778feada80bab38c78581.zip | |
add dropdown tab selection support
Diffstat (limited to 'js')
| -rw-r--r-- | js/bootstrap-tabs.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/js/bootstrap-tabs.js b/js/bootstrap-tabs.js index e8e2dc622..9ccf85436 100644 --- a/js/bootstrap-tabs.js +++ b/js/bootstrap-tabs.js @@ -21,24 +21,33 @@ !function( $ ){ function activate ( element, container ) { - container.find('> .active').removeClass('active') + container + .find('> .active') + .removeClass('active') + .find('> .dropdown-menu > .active') + .removeClass('active') + element.addClass('active') + + if ( element.parent('.dropdown-menu') ) { + element.closest('li.dropdown').addClass('active') + } } function tab( e ) { var $this = $(this) - , $ul = $this.closest('ul') + , $ul = $this.closest('ul:not(.dropdown-menu)') , href = $this.attr('href') , previous - if (/^#\w+/.test(href)) { + if ( /^#\w+/.test(href) ) { e.preventDefault() - if ($this.parent('li').hasClass('active')) { + if ( $this.parent('li').hasClass('active') ) { return } - previous = $ul.find('.active a')[0] + previous = $ul.find('.active a').last()[0] $href = $(href) activate($this.parent('li'), $ul) |
