mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-03 15:24:19 +01:00
Add jquery.ready hook after defining plugin, to avoid breakage when used with modernizr/yepnope
See https://gist.github.com/1258742 for an example, which results in the error "TypeError: Object has no method 'dropdown' at bootstrap-dropdown.js line 31" It looks like in these circumstances, the functions hooked into jquery.ready get run immediately, and so applying the dropdown behavior to specific elements before defining the 'dropdown' method causes breakage.
This commit is contained in:
parent
7e01ff8a15
commit
bdbb1c92aa
27
js/bootstrap-dropdown.js
vendored
27
js/bootstrap-dropdown.js
vendored
@ -20,17 +20,6 @@
|
|||||||
|
|
||||||
!function( $ ){
|
!function( $ ){
|
||||||
|
|
||||||
var d = 'a.menu, .dropdown-toggle'
|
|
||||||
|
|
||||||
function clearMenus() {
|
|
||||||
$(d).parent('li').removeClass('open')
|
|
||||||
}
|
|
||||||
|
|
||||||
$(function () {
|
|
||||||
$('html').bind("click", clearMenus)
|
|
||||||
$('body').dropdown( '[data-dropdown] a.menu, [data-dropdown] .dropdown-toggle' )
|
|
||||||
})
|
|
||||||
|
|
||||||
/* DROPDOWN PLUGIN DEFINITION
|
/* DROPDOWN PLUGIN DEFINITION
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
@ -47,4 +36,18 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}( window.jQuery || window.ender );
|
/* APPLY TO STANDARD DROPDOWN ELEMENTS
|
||||||
|
* =================================== */
|
||||||
|
|
||||||
|
var d = 'a.menu, .dropdown-toggle'
|
||||||
|
|
||||||
|
function clearMenus() {
|
||||||
|
$(d).parent('li').removeClass('open')
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
$('html').bind("click", clearMenus)
|
||||||
|
$('body').dropdown( '[data-dropdown] a.menu, [data-dropdown] .dropdown-toggle' )
|
||||||
|
})
|
||||||
|
|
||||||
|
}( window.jQuery || window.ender );
|
||||||
|
Loading…
Reference in New Issue
Block a user