This was a bug in jQueryUI. It's being addressed.
jQueryUI on("menuselect") not firing every time
-
04-06-2022 - |
Question
Creating a menu with jQueryUI, I noticed that if you select a menuitem, it fires the appropriate event properly. However, if you then select another menuitem right away (without clicking on anything outside the menu first), it does not fire the menuselect event and simply treats the a
tag as a regular link (this pattern repeats: 1 okay, 1 ignored, 1 okay, 1 ignored, etc...)
Here is a jsfiddle that demonstrates the issue: http://jsfiddle.net/J9eyv/4/
(1) Broken: Click an option, then click another one.
(2) Works: Click an option, click outside the menu, then click another option.
The code is modeled after the jQueryUI demo here: http://api.jqueryui.com/menu/#event-select
Am I missing something?
EDIT:
If you call $(selector).menu("focus"
) or, indeed, $(selector).menu("idontunderstand")
, from the event callback, this 'fixes' the issue. That doesn't sound right.
Solution
OTHER TIPS
I'm not sure about "menuselect" you're using but it works fine if you do this:
$("#menu").menu();
$("#menu a").click(function() {
alert($(this).attr("href"));
return false;
});