Popup help boxes in Jquery
I already have this working in standard javascript, but I'm trying to learn Jquery so trying to translate it. Here's the function so far:
-
function jsearchPopHelp(caller,text,right)
{
$jsq("#jsearch_help_pop").html(text);
callerP = $jsq(caller).offset();
$jsq("#jsearch_help_pop").show();
$jsq("#jsearch_help_pop").css('top',callerP.top);
if (!right) // Pop to the right
$jsq("#jsearch_help_pop").css('left',callerP.left+$jsq(caller).width()+3);
else
$jsq("#jsearch_help_pop").css('left',callerP.left-$jsq("#jsearch_help_pop").width());
setTimeout("jsearchPopAdjuster('jsearch_help_pop')",200);
}
This works, but of course when the popup opens, it triggers the mouseout event immediately since the mouse is over the hovering box and not the object that triggered the help box in the first place.
I'm trying to set a variable to prevent the function from turning off the box while the mouse is over the help box like this:
-
$jsq("#jsearch_help_pop").hover(
function () {
helpOpen = true;
},
function () {
helpOpen = false;
jsearchPopHelpOff();
}
);
But this throws and error saying that helpOpen is not defined. I could set it as a global variable, but I'm really getting the feeling that I'm doing this way wrong. Anyone have any advice on what I should be doing here?