Re: [jQuery] bind two events to same function

2007-03-28 Thread Klaus Hartl
David Dexter schrieb: I have my dunce cap… which corner do I go sit in? Hm, actually why shouldn't one be able to use the same function in hover? -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/

Re: [jQuery] bind two events to same function

2007-03-28 Thread Juha Suni
get from the targeted element (this) or the event object, then you might need to wrap some stuff in a dynamic function. -- Suni - Original Message - From: Aaron Heimlich To: jQuery Discussion Sent: Wednesday, March 28, 2007 1:02 AM Subject: Re: [jQuery] bind two events

Re: [jQuery] bind two events to same function

2007-03-28 Thread Klaus Hartl
Juha Suni schrieb: Maybe I'm missing something but I don't see the difficulty here. There's definately no need to do excessive core hacking or chaining of mouseover and mouseout... Why not just: function myFunction() { $(this).append(' hover!'); } And then:

Re: [jQuery] bind two events to same function

2007-03-28 Thread Juha Suni
Klaus Hartl wrote: Another pattern for this would be a function that returns a function (or maybe you meant that with dynamic function): function myFunction(s) { return function() { $(this).append(s); }; } $('#hoverelem').hover(myFunction('foo'), myFunction('bar')); Ah,

[jQuery] bind two events to same function

2007-03-27 Thread Josh Nathanson
What is the syntax to bind two events to the same function? I want to do something like $([EMAIL PROTECTED]).bind(mouseover,mouseout, function() { stuff here }); But it doesn't work. TIA -- Josh ___ jQuery mailing list discuss@jquery.com

Re: [jQuery] bind two events to same function

2007-03-27 Thread David Dexter
To: jQuery Discussion. Subject: [jQuery] bind two events to same function What is the syntax to bind two events to the same function? I want to do something like $([EMAIL PROTECTED]).bind(mouseover,mouseout, function() { stuff here }); But it doesn't work. TIA -- Josh

Re: [jQuery] bind two events to same function

2007-03-27 Thread Blair Mitchelmore
Or if you wanted to hack jQuery a bit for some syntactic sugar: jQuery.fn._bind = jQuery.fn.bind; jQuery.fn.bind = function(names,action) { var self = this; jQuery.each(names.split(/\s*,\s*/),function() { self.bind(this,action); }; return this; }; That code might not

Re: [jQuery] bind two events to same function

2007-03-27 Thread Josh Nathanson
Yup, Aaron's got it...it worked. Thanks! -- Josh - Original Message - From: Aaron Heimlich To: jQuery Discussion Sent: Tuesday, March 27, 2007 3:02 PM Subject: Re: [jQuery] bind two events to same function On 3/27/07, David Dexter [EMAIL PROTECTED] wrote: Have a look

Re: [jQuery] bind two events to same function

2007-03-27 Thread Aaron Heimlich
On 3/27/07, David Dexter [EMAIL PROTECTED] wrote: Have a look at the hover() function it does exactly what you are looking for. Actually, it doesn't. hover() expects two different functions. From the API docs: Whenever the mouse cursor is moved over a matched element, the first specified

Re: [jQuery] bind two events to same function

2007-03-27 Thread Aaron Heimlich
I'm pretty sure your code would cause an infinite loop. It should probably be (untested): jQuery.fn._bind = jQuery.fn.bind; jQuery.fn.bind = function(names,action) { var self = this; jQuery.each(names.split(/\s*,\s*/),function() { self._bind(this,action); // self._bind(), not

Re: [jQuery] bind two events to same function

2007-03-27 Thread Blair Mitchelmore
You're right, thanks for catching that. -blair Aaron Heimlich wrote: I'm pretty sure your code would cause an infinite loop. It should probably be (untested): jQuery.fn._bind = jQuery.fn.bind; jQuery.fn.bind = function(names,action) { var self = this; jQuery.each

Re: [jQuery] bind two events to same function

2007-03-27 Thread David Dexter
] bind two events to same function On 3/27/07, David Dexter [EMAIL PROTECTED] wrote: Have a look at the hover() function it does exactly what you are looking for. Actually, it doesn't. hover() expects two different functions. From the API docs: Whenever the mouse cursor is moved over

Re: [jQuery] bind two events to same function

2007-03-27 Thread Mike
Have a look at the hover() function it does exactly what you are looking for. Actually, it doesn't. hover() expects two different functions. From the API I think David meant look at the actual implementation. ___ jQuery mailing list