Reputation: 2265
I have a contextmenu that shows on certain elements when you right click. This works no problem.
wrapper.on('contextmenu', 'div.outer', function (e) {
context_menu.css({
left: e.pageX,
top: e.pageY,
zIndex: '101'
}).fadeIn();
return false;
});
//This does not work correctly
context_menu.mouseout(function (e) {
$(this).fadeOut();
});
I'm trying to figure out how to hide the menu when the user is not hovered over the menu. Right now as soon as I move the mouse after I right click it fades out.
Upvotes: 1
Views: 900
Reputation: 144689
$(selector).hover(handlerIn, handlerOut);
is shorthand for:
$(selector).mouseenter(handlerIn).mouseleave(handlerOut);
Upvotes: 0
Reputation: 78991
The events, should most probably be mouseleave
since its a container.
context_menu.mouseleave(function (e) {
$(this).fadeOut();
});
Upvotes: 1
Reputation: 822
Look here: http://api.jquery.com/hover/
the hover() event has one method for when the mouse is over the element and one for when it's not.
Upvotes: 0