[jQuery] Re: how could I unbind .hover() ?

2007-06-22 Thread March
thank you all! :D

On 6/22/07, Erik Beeson <[EMAIL PROTECTED]> wrote:
>
>
> Doh! And I knew that too! 6am is too late to be trying to answer
> questions. My second suggestion would still work though. And I
> reiterate that it is probably the ideal solution.
>
> Thanks for the heads up.
>
> --Erik
>
>
> On 6/22/07, Brandon Aaron <[EMAIL PROTECTED]> wrote:
> > Unfortunately this won't work when using the hover helper method. The
> hover
> > helper method assigns an anonymous method to both the mouseover and
> mouseout
> > events. This anonymous function then decides if it should fire the given
> > mouseover or mouseout functions provided to .hover().
> >
> > --
> > Brandon Aaron
> >
> >
> > On 6/22/07, Erik Beeson <[EMAIL PROTECTED]> wrote:
> > >
> > > In addition to Brandon's suggestion, you could also used named
> > > functions instead of anonymous functions if you only want to remove
> > > the hover events instead of all mouseover/mouseout events:
> > >
> > > function hoverOn() {
> > >...
> > > }
> > > function hoverOff() {
> > >...
> > > }
> > >
> > > $(...).hover(hoverOn, hoverOff);
> > > $(...).unbind('mouseover', hoverOn).unbind('mouseout', hoverOff);
> > >
> > > But probably the easiest way to deal with it is to have your hover
> > > functions check some state before doing the hover effects, and then
> > > don't worry about unbinding them:
> > >
> > > $(...).hover(function() {
> > >   if(/* check for something */) {
> > >   // do hover stuff here
> > >}
> > > }, function() {
> > >   if(/* check for something */) {
> > >   // do unhover stuff here
> > >}
> > > });
> > >
> > > The check would be specific to your application.
> > >
> > > --Erik
> > >
> > >
> > > On 6/22/07, March < [EMAIL PROTECTED]> wrote:
> > > > i did something like this:
> > > >
> > > > $('div').hover(function(){
> > > > // do something
> > > > },function(){
> > > > // do something else
> > > > });
> > > >
> > > > but after some event, i need to disable the hover effect, is there
> any
> > easy
> > > > way to do this?
> > > >
> > > > thanks
> > > >
> > > > --
> > > > Zacky Ma
> > > > www.marchbox.com
> > >
> >
> >
>



-- 
Zacky Ma
www.marchbox.com


[jQuery] Re: how could I unbind .hover() ?

2007-06-22 Thread Erik Beeson


Doh! And I knew that too! 6am is too late to be trying to answer
questions. My second suggestion would still work though. And I
reiterate that it is probably the ideal solution.

Thanks for the heads up.

--Erik


On 6/22/07, Brandon Aaron <[EMAIL PROTECTED]> wrote:

Unfortunately this won't work when using the hover helper method. The hover
helper method assigns an anonymous method to both the mouseover and mouseout
events. This anonymous function then decides if it should fire the given
mouseover or mouseout functions provided to .hover().

--
Brandon Aaron


On 6/22/07, Erik Beeson <[EMAIL PROTECTED]> wrote:
>
> In addition to Brandon's suggestion, you could also used named
> functions instead of anonymous functions if you only want to remove
> the hover events instead of all mouseover/mouseout events:
>
> function hoverOn() {
>...
> }
> function hoverOff() {
>...
> }
>
> $(...).hover(hoverOn, hoverOff);
> $(...).unbind('mouseover', hoverOn).unbind('mouseout', hoverOff);
>
> But probably the easiest way to deal with it is to have your hover
> functions check some state before doing the hover effects, and then
> don't worry about unbinding them:
>
> $(...).hover(function() {
>   if(/* check for something */) {
>   // do hover stuff here
>}
> }, function() {
>   if(/* check for something */) {
>   // do unhover stuff here
>}
> });
>
> The check would be specific to your application.
>
> --Erik
>
>
> On 6/22/07, March < [EMAIL PROTECTED]> wrote:
> > i did something like this:
> >
> > $('div').hover(function(){
> > // do something
> > },function(){
> > // do something else
> > });
> >
> > but after some event, i need to disable the hover effect, is there any
easy
> > way to do this?
> >
> > thanks
> >
> > --
> > Zacky Ma
> > www.marchbox.com
>




[jQuery] Re: how could I unbind .hover() ?

2007-06-22 Thread Brandon Aaron

Unfortunately this won't work when using the hover helper method. The hover
helper method assigns an anonymous method to both the mouseover and mouseout
events. This anonymous function then decides if it should fire the given
mouseover or mouseout functions provided to .hover().

--
Brandon Aaron

On 6/22/07, Erik Beeson <[EMAIL PROTECTED]> wrote:



In addition to Brandon's suggestion, you could also used named
functions instead of anonymous functions if you only want to remove
the hover events instead of all mouseover/mouseout events:

function hoverOn() {
   ...
}
function hoverOff() {
   ...
}

$(...).hover(hoverOn, hoverOff);
$(...).unbind('mouseover', hoverOn).unbind('mouseout', hoverOff);

But probably the easiest way to deal with it is to have your hover
functions check some state before doing the hover effects, and then
don't worry about unbinding them:

$(...).hover(function() {
  if(/* check for something */) {
  // do hover stuff here
   }
}, function() {
  if(/* check for something */) {
  // do unhover stuff here
   }
});

The check would be specific to your application.

--Erik


On 6/22/07, March <[EMAIL PROTECTED]> wrote:
> i did something like this:
>
> $('div').hover(function(){
> // do something
> },function(){
> // do something else
> });
>
> but after some event, i need to disable the hover effect, is there any
easy
> way to do this?
>
> thanks
>
> --
> Zacky Ma
> www.marchbox.com



[jQuery] Re: how could I unbind .hover() ?

2007-06-22 Thread Erik Beeson


In addition to Brandon's suggestion, you could also used named
functions instead of anonymous functions if you only want to remove
the hover events instead of all mouseover/mouseout events:

function hoverOn() {
  ...
}
function hoverOff() {
  ...
}

$(...).hover(hoverOn, hoverOff);
$(...).unbind('mouseover', hoverOn).unbind('mouseout', hoverOff);

But probably the easiest way to deal with it is to have your hover
functions check some state before doing the hover effects, and then
don't worry about unbinding them:

$(...).hover(function() {
 if(/* check for something */) {
 // do hover stuff here
  }
}, function() {
 if(/* check for something */) {
 // do unhover stuff here
  }
});

The check would be specific to your application.

--Erik


On 6/22/07, March <[EMAIL PROTECTED]> wrote:

i did something like this:

$('div').hover(function(){
// do something
},function(){
// do something else
});

but after some event, i need to disable the hover effect, is there any easy
way to do this?

thanks

--
Zacky Ma
www.marchbox.com


[jQuery] Re: how could I unbind .hover() ?

2007-06-22 Thread Brandon Aaron

The hover bind a mouseover and mouseout event and you can remove them by
doing the following:

$('div').unbind('mouseover').unbind('mouseout');

--
Brandon Aaron

On 6/22/07, March <[EMAIL PROTECTED]> wrote:


i did something like this:

$('div').hover(function(){
// do something
},function(){
// do something else
});

but after some event, i need to disable the hover effect, is there any
easy way to do this?

thanks

--
Zacky Ma
www.marchbox.com