i've defined jqueryui menu id leftmenu
, on list elements, have defined function on clicking 1 item, follows:
$('#leftmenu>li').click(function () { var clickedid = this.id; $.ajax({ type: "post", cache: false, url: "/session/index/", success: function (result) { if (result.length > 0) { performlistitemaction(clickedid); } else { window.location.href = '/home/index/' } } }); });
this works fine, want change instead of click
on menu item, want capture focus , selection on item in more general way, such using keyboard. currently, can navigate through menu using , down keys on keyboard, inner code not called. know because supposed happen on click
, same thing happpened when tried activate
, focus
in place of click
well.
how can perform same behavior click
in more general way captures selection , enter of menu item?
thank you.
this should done in select
event. way catches both click
or select
focused keyboard actions.
example: https://jsfiddle.net/twisty/v671x6ns/
jquery
$(function() { $('#leftmenu').menu({ select: function(e, ui) { var selectid = ui.item.attr("id"); $.ajax({ type: "post", cache: false, url: "/session/index/", success: function(result) { if (result.length > 0) { performlistitemaction(selectid); } else { window.location.href = '/home/index/' } } }); console.log(e.type + " event, id: " + selectid); } }); });
Comments
Post a Comment