]> source.dussan.org Git - jquery-ui.git/commitdiff
Create mouseHandled flag per instance instead of globally. Fixes #8866 - Menu: select...
authorKris Borchers <kris.borchers@gmail.com>
Fri, 28 Dec 2012 03:06:06 +0000 (21:06 -0600)
committerKris Borchers <kris.borchers@gmail.com>
Fri, 28 Dec 2012 03:06:54 +0000 (21:06 -0600)
ui/jquery.ui.menu.js

index 8d99272d08d1eb1dd0e7cc657a7c4ef6c7107bf3..3c445eca1fd6a88afc2dfe7f190d91ee6f2a5456 100644 (file)
@@ -15,8 +15,6 @@
  */
 (function( $, undefined ) {
 
-var mouseHandled = false;
-
 $.widget( "ui.menu", {
        version: "@VERSION",
        defaultElement: "<ul>",
@@ -40,6 +38,7 @@ $.widget( "ui.menu", {
 
        _create: function() {
                this.activeMenu = this.element;
+               this.mouseHandled = false;
                this.element
                        .uniqueId()
                        .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
@@ -73,8 +72,8 @@ $.widget( "ui.menu", {
                        },
                        "click .ui-menu-item:has(a)": function( event ) {
                                var target = $( event.target ).closest( ".ui-menu-item" );
-                               if ( !mouseHandled && target.not( ".ui-state-disabled" ).length ) {
-                                       mouseHandled = true;
+                               if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
+                                       this.mouseHandled = true;
 
                                        this.select( event );
                                        // Open submenu on click
@@ -130,7 +129,7 @@ $.widget( "ui.menu", {
                                }
 
                                // Reset the mouseHandled flag
-                               mouseHandled = false;
+                               this.mouseHandled = false;
                        }
                });
        },