[UPHPU] jquery: hover(over,out)

Richard K Miller richardkmiller at gmail.com
Tue Dec 9 13:04:14 MST 2008


On Dec 8, 2008, at 11:19 PM, Wade Preston Shearer wrote:

> On 8 Dec 2008, at 23:12, Richard K Miller wrote:
>
>> Does this work?
>>
>> $('tr').hover(banana, banana);
>>
>> This passes the functions themselves instead of the values that the  
>> functions returned.
>
> Interesting; it does. My problem isn't solved however because in my  
> real code (my example was simplified), I need to pass values into  
> the functions like this:
>
> $('tr').hover(banana(a,b), banana(a,b));

You could pass a and b to a function that returns an anonymous  
function with the behavior you want:

$('tr').hover(banana_stand(a,b), banana_stand(a,b));

function banana_stand(a, b)
{
   return function () { /* do something with a and b */ } // return a  
banana(), but it won't be executed until hover() calls for it
}




More information about the UPHPU mailing list