I have a Superfish menu item that has 2 text inputs, I want to make sure the menu does not get closed (hidden) if one of these fields has the user's focus.
I have everything for this except I don't know how to stop the Superfish Hide event execution.
jQuery(function () {
jQuery('ul.sf-menu').superfish({
onBeforeHide: function () {
$('ul.sf-menu').find('input[type=text], input[type=password]').each(function () {
if ($(this).is(':focus')) {
//need code to stop Superfish Hide execution here
}
});
},
delay: 500
});
});
How can I stop the hide event execution?
Well, this is fixed. I had to change the plugin code itself:
if ($ul.find('input[type=text]:focus, input[type=password]:focus ').length == 0){
$ul.stop(true, true).animate(o.animationOut, speed, function () {
var $this = $(this);
o.onHide.call($this);
});
}
else{
$(this).addClass(o.hoverClass);
}
The idea is to count a number of text inputs that have user's focus at the moment, if there's more than one, add the hoverClass
which makes the menu item stay visible. If there's no focused items, it will proceed with hiding as usual.