It's not unbinding the click for me when I don't return false. I put
the 'unbind' in there in the first place because if the function gets
called again (that does the event binding)... I don't want the event
handler to execute 2, 3, 4, 5... etc times instead of only once.

Thanks again folks! =)

On May 20, 6:25 pm, "Jean Nascimento" <[EMAIL PROTECTED]> wrote:
> with this changes works
>
>  $('body').unbind('click').click(function(event) {
>                if($(event.target).is('#test')) { alert("Returning..");
>                                 return true; }
>
>                // Do whatever here.
>                alert("Would perform some action.");
>                            return false;
>        });
>
> couze we use the unbind function for that we need return false when
> the click is in body or will unbind the click for the body ;D
>
> On 5/20/07, MikeR <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Brandon, very good! Much appreciated!! =) I had to put "event" as a
> > parameter inside of the function() {...} snippet, but yes.. that is
> > *exactly* what I was looking for.
>
> > Here is the test code in case anybody else happens to run into this
> > problem and needs a solution:
>
> > <html>
> > <head>
> > <title></title>
> > <script language="javascript" src="http://labs.twerq.com/
> > jquery.pack.js"></script>
> > <script type="text/javascript">
> > $(document).ready(function() {
> >         $('body').unbind('click').click(function(event) {
> >                 if($(event.target).is('#test')) { alert("Returning.."); 
> > return
> > false; }
>
> >                 // Do whatever here.
> >                 alert("Would perform some action.");
> >         });
> > });
> > </script>
> > </head>
> > <body>
>
> > <span id="test" style="border: 1px solid blue;">[x]</span>
>
> > </body>
> > </html>
>
> > On May 20, 5:50 pm, "Brandon Aaron" <[EMAIL PROTECTED]> wrote:
> > > I would just check the event.target to see if it originated from the 
> > > image.
>
> > > $('body').bind('click', function() {
> > >     if ( $(event.target).is('#someId') ) return; // short-circuit
> > >     // continue on to hide div
>
> > > });
>
> > > --
> > > Brandon Aaron
>
> > > On 5/20/07, MikeR <[EMAIL PROTECTED]> wrote:
>
> > > > Just a quick question =).
>
> > > > I want to bind an event handler to "body" so that whenever someone
> > > > clicks anywhere on the body, a DIV disappears. However, there is a
> > > > specific graphic (that has an id) that I need to be ignored in that
> > > > click handler. I haven't been able to come up with an elegant solution
> > > > and was hoping someone here may have some advice.
>
> > > > I've tried something along the lines of: $
> > > > ('body').not('#someid').unbind('click').click(function() { /* code
> > > > */ });
>
> > > > But it does not work. Any thoughts?
>
> --
>
> []´s Jeanwww.suissa.info
>
>    Ethereal Agencywww.etherealagency.com

Reply via email to