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/
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
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:
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,
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
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
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
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
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
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
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
] 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
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
13 matches
Mail list logo