Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery hoverIntent: 'Uncaught TypeError: Cannot call method 'apply' of undefined'

I'm using Brian Cherne's hoverIntent.js plugin for a project. It's a great plugin but it seems to be broken in jQuery 1.7.1.

I'm trying to debug it but I'm not the most ace javascripter out there. Can anyone tell me what I might need to look for in his code to fix the following error message:

Uncaught TypeError: Cannot call method 'apply' of undefined

That's what my Chrome console tells me. I'm just not sure what to change.

There is the following line of code in the plugin which contains apply in the string

return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};

EDIT

I should post the link to Brian's full commented code. It's here: http://cherne.net/brian/resources/jquery.hoverIntent.js

EDIT 2

My script is as follows

//#nav-main dropdown effects                
$('#nav-main ul li').hoverIntent(function () {
   $(this).find('.dropdown').stop(true,true).slideToggle('500');
});
like image 400
Brian Avatar asked Dec 04 '11 09:12

Brian


1 Answers

Basically hoverIntent requires two functions or one object.

If you put in just one function, it will try to use your function as object and you can't apply a function! So use:

$('#nav-main ul li').hoverIntent(function () {
    $(this).find('.dropdown').stop(true,true).slideToggle('500');
}, function(){});
like image 58
noob Avatar answered Nov 16 '22 00:11

noob