]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add jquery.ready hook after defining plugin, to avoid breakage when used with moderni... 362/head
authorSteve Purcell <steve@sanityinc.com>
Mon, 3 Oct 2011 09:05:43 +0000 (10:05 +0100)
committerSteve Purcell <steve@sanityinc.com>
Mon, 3 Oct 2011 09:05:43 +0000 (10:05 +0100)
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.

js/bootstrap-dropdown.js

index a3b0b0dfa44613b3a0b77c9b77ece78c49f5050d..68a3db5f2052f2e43dde4e9aaced432eb9212c80 100644 (file)
 
 !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
    * ========================== */
 
     })
   }
 
-}( window.jQuery || window.ender );
\ No newline at end of file
+  /* 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 );