diff options
| author | Mark Otto <[email protected]> | 2011-12-21 18:39:02 -0600 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2011-12-21 18:39:02 -0600 |
| commit | 9fb380151d477f1741b7609ade7a9e7fd5450b2c (patch) | |
| tree | a749f2b6917c09770af1586ae9f83e46115de7eb /js/bootstrap-dropdown.js | |
| parent | 12a0d69454a2831031035d19237d36d38bb2c2a9 (diff) | |
| parent | a5a98a8a984512011dac1216b432b86c6eff96a4 (diff) | |
| download | bootstrap-9fb380151d477f1741b7609ade7a9e7fd5450b2c.tar.xz bootstrap-9fb380151d477f1741b7609ade7a9e7fd5450b2c.zip | |
Merge branch '2.0-wip' of github.com:twitter/bootstrap into 2.0-wip
Conflicts:
bootstrap.css
docs/javascript.html
Diffstat (limited to 'js/bootstrap-dropdown.js')
| -rw-r--r-- | js/bootstrap-dropdown.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/js/bootstrap-dropdown.js b/js/bootstrap-dropdown.js index 238a52e08..15f4677b9 100644 --- a/js/bootstrap-dropdown.js +++ b/js/bootstrap-dropdown.js @@ -35,11 +35,15 @@ constructor: Dropdown , toggle: function ( e ) { - var li = $(this).parent('li') - , isActive = li.hasClass('open') + var $this = $(this) + , selector = $this.attr('data-target') || $this.attr('href') + , $parent = $(selector) + + $parent.length || ($parent = $this.parent()) clearMenus() - !isActive && li.toggleClass('open') + + !$parent.hasClass('open') && $parent.toggleClass('open') return false } @@ -47,7 +51,7 @@ } function clearMenus() { - $(toggle).parent('li').removeClass('open') + $(toggle).parent().removeClass('open') } @@ -63,13 +67,15 @@ }) } + $.fn.dropdown.Constructor = Dropdown + /* APPLY TO STANDARD DROPDOWN ELEMENTS * =================================== */ $(function () { - $('html').bind('click.dropdown.data-api', clearMenus) - $('body').delegate(toggle, 'click.dropdown.data-api', Dropdown.prototype.toggle) + $('html').on('click.dropdown.data-api', clearMenus) + $('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle) }) -}( window.jQuery || window.ender )
\ No newline at end of file +}( window.jQuery )
\ No newline at end of file |
