Create mouseHandled flag per instance instead of globally. Fixes #8866 - Menu: select event not firing due to mouseHandled flag reset bug

This commit is contained in:
Kris Borchers 2012-12-27 21:06:06 -06:00
parent 2c3d311f90
commit 5143b7f672

View 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;
}
});
},