Hareesh Hareesh - 6 months ago 18
Javascript Question

jQuery slide delay for Joomla yt megamenu plugin

I have a working Joomla extension (YT Mega menu). I want to make some updates to the existing code.

Here is the code for

mouseenter
and
mouseleave
:

li.addEvent('mouseenter', function (e) {
//if (objectReference.hasOpenning) return;
log('enter parent of ' + (ul ? ul.id : 'li has not child'));
li.addClass('hover');
if (ulexists) {
objectReference.showChild(ul);
}
});
li.addEvent('mouseleave', function (e) {
log('leave parent of ' + (ul ? ul.id : 'li has not child'));
li.removeClass('hover');
if (ulexists) {
if (ul.pinned) return false;
objectReference.hideChild(ul);
}
});


On
mouseleave
i want a delay before hiding the
ul
.
is there any way to do this?

Please help. I am a beginner and confused.

Answer

Change

objectReference.hideChild(ul);

To

setTimeout(function(){ 
    objectReference.hideChild(ul); 
},time);

time in milliseconds.