Thank you Josh, that triggered something - 

 

that I am not asking very good questions, 

 

and that I had just finished reading about bubbling in Karl's L J Q chap 3.
I understand that is when an event like a click  travels up the DOM to other
elements and you want it to stop. Karl presents the event object as a
solution (I don't recall that he used return to solve it), and he also shows
how to remove event handlers. But no return. 

 

Thing is my problem doesn't seem to fit this allegory, because I have one
div with two conflicting events, mouseover and mouseout. 

 

Like this 

http://www.whatbird.com/wwwroot/3statebutton_framed.html

 

In my example the button and graphic inside theframe appear during a
mouseover and disappear on a mouse out. I set it up like this

 

   $("#nest").mouseover(function() {

                $("#nest").fadeOut(500);

                $("#But1frm").fadeIn(500);

   });        

   

                $("#nest").mouseout(function() {

                $("#nest").fadeIn(500);

                $("#But1frm").fadeOut(500);

   });        

 

And I got this result

 

http://www.whatbird.com/wwwroot/3statebutton_framed.html

 

2 pulses for every mouseover giving this hypnotic effect which might be
useful at some point J  but is not what I want .

 

The solution was pretty simple. Can you see what I did?

 

http://www.whatbird.com/wwwroot/3statebutton_framed_2.html

 

Note that the small green jQuery 3 State button still works.

 

Now my question is can I add an "effect" to the mouseover handler so the
nest fades in an fades out?

 

Mitch

 

From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Josh Nathanson
Sent: Thursday, July 26, 2007 3:33 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Boggles the mind - mousevoer and mouseout together

 

Ahah, now you are delving a bit deeper.  This is where things get a bit
tricky.

 

What you want to do is add a "return false;" to your mouseover event
handler.  This is to stop what is known as "event bubbling", that is to say,
an event which occurs on an inner element will propagate up through the DOM,
and any other event handlers will be triggered.

 

NOW, I've found that if you use the hover method, returning false will not
stop the event bubbling.  In these cases I had to break out my mouse events
into mouseover and mouseout.

 

So, suppose you have something like:

<div id="1">

    <div id="2">

    hello!

    </div>

</div>

 

And you have mouseover handlers for both #1 and #2.

 

You might do something like:

$("#2").mouseover(function() {

    dosomething();

    return false;

});

 

This will stop your div#1 from receiving the mouseover event while the mouse
is within div#2.  I believe this basic approach of returning false will work
for all the mouse events, but for whatever reason (I'm sure there's a good
one) it won't work in the hover method.

 

I didn't follow your example entirely, but it sounds like something like
this is occurring.

 

-- Josh

----- Original Message ----- 

From: Mitchell Waite <mailto:[EMAIL PROTECTED]>  

To: jquery-en@googlegroups.com 

Sent: Thursday, July 26, 2007 3:05 PM

Subject: [jQuery] Boggles the mind - mousevoer and mouseout together

 

Imagine this

 

When a user moves the mouse over a certain div (mouseover) on your page you
want to do some things

 

1. fadeOut a graphic in that div to 50%

2. Make a button in that div appear (show)

3. Manipulate the button's 3 states (my wonderful 3 state button gizmo)

 

4.   When the user clicks the mouse call function A and reverse the above,
fadeIn the graphic back to 100%, hide the button.

5. If the user moves the mouse out of the div area (mouseout) then reverse
the above, fadeIn the graphic back to 100%, hide the button.

 

Sounds easy right? Well it's not. Why? 

 

Because of the way jQuery queues up the events, the a mouseover and a
mouseout events interact in such a way that the whole process goes bananas,
there is a great deal of flickering of the graphics when you move the mouse
because it is sending mouseover messages.

 

What I need to do is to have it act more like hover, which avoids these
issues. Except for one problem. I am using a button over the graphic that
uses hover also. So the two processes fight eachother.

 

I need a way to say

 

jQuery - I need you to do something a bit different.

Respond to my mouseover as usual but then don't look at mouseover for a
while.

That way I could process the other events.

 

Any ideas on how to do this. I thought perhaps using a call back would help
but that seems to just let me control one thing finishing before another
starts which is not my issue.

 

Thanks

 

Mitch

 

 

Reply via email to