I use hoverIntent, which, as part of its settings, will call a function. I think this is called a "function reference" (right?):
var HIconfig = { interval: 250, sensitivity: 8, over: myFunction, timeout: 100, out: myOtherFunction };
However, I would like to reuse the specified function at times and explicitly pass the jQuery object. So, I added this to the function.
myFunction($myObject){ }
The challenge now is to find out when the function refers to hoverIntent or is explicitly called. I thought I would check if $ (this) would contain a specific DOM element:
myFunction($myObject){ if($(this).is('li')){ $myObject = $(this) }; $myObject.doSomething... }
But ... I have a problem. If I exit both $ (this) and $ myObject, these will be the following results:
Called via hoverIntent:
$(this) = [li
Called by direct object transfer
$(this) = [Window PT02-home-page.php
I can check $(this).is('li') in the first script, as that is true.
I cannot in the second, although when I try to run the test, Firefox does not like it:
g.nodeName is undefined
One suggestion was to switch to 1.4.1 and try to check the opposite via .isPlayObject:
if (jQuery.isPlainObject($myObject))...
This works great in Firefox. However, IE8 always returns true.
My questions:
Is my logic just remote in terms of how my function is called from hoverIntent or directly?
If not, is there a way to test sequentially so that I explicitly pass the object to my variable in this function?