function banana() {
alert('banana function called');
}
$('tr').hover(banana, banana);
You can use this code still -- basically what you're doing is setting up a
delegate to call an event handler -- event handlers only accept one
argument, e, which contains the event information including the object from
which the event came. So your banana function will actually be banana(e),
like this:
function banana(e) {
var target;
if(!e) var e = window.event;
if(e.target) {
target = e.target;
} else if(e.srcElement) {
target = e.srcElement;
}
}
>From there you might call another function that takes multiple arguments.
Does that make sense?
On Tue, Dec 9, 2008 at 8:50 AM, Joseph Scott <[EMAIL PROTECTED]>wrote:
>
> On Dec 8, 2008, at 11:07 PM, Wade Preston Shearer wrote:
>
>
>>> Because hover() takes Functions as arguments, and what you are doing is
>>> calling the functions when setting up the hover event.
>>>
>>
>> I considered "takes Functions as arguments" and "calling the functions" as
>> the same thing. The documentation words it as the "specified function is
>> fired." It doesn't specify that the functions have to be anonymous, in-line
>> functions. Too bad; I would have liked to have called external functions and
>> not repeated code.
>>
>
>
>
> Calling functions and passing functions (which can be anonymous or
> addressed as a variable) are completely different. Calling a function will
> cause it to be fired immediately, by passing and an anonymous function or
> function reference this allows jQuery to fire them at the appropriate time.
> That's really the key to why they need to be referenced functions, so that
> .hover() can control when they are fired.
>
> There's nothing stopping your from calling your external function, as the
> hover example showed:
>
> http://docs.jquery.com/Events/hover#overout
>
> What you're trying to do is avoid the extra 12 characters (or more with
> spaces) per argument to the .hover() function.
>
>
> --
> Joseph Scott
> [EMAIL PROTECTED]
> http://josephscott.org/
>
>
>
>
>
> _______________________________________________
>
> UPHPU mailing list
> [email protected]
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
>
--
Nathan Lane
Home, http://www.nathandelane.com
Blog, http://nathandelane.blogspot.com
_______________________________________________
UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net