[jQuery] Re: Capture a click outside of a specific object?

2009-01-15 Thread vincent voyer
You can do : $(document).bind('click', function(e){ var $clicked = $(e.target); if (!($clicked.is('#element') || $clicked.parents().is ('#element'))) { //click outside,

[jQuery] Re: Capture a click outside of a specific object?

2009-01-14 Thread riotbrrd
Hmmm, I wasn't able to find anything about that, though I checked only quickly. What section fo the docs would that be in? On Jan 13, 5:44 pm, Kean wrote: > You might want to look at live and die method now posted in jQuery > documentation. > > On Jan 13, 11:32 am,riotbrrd wrote: > > > > > Hi al

[jQuery] Re: Capture a click outside of a specific object?

2009-01-14 Thread riotbrrd
Thanks, Sam! I had to make one change, then it worked. I got an error message that "event" was undefined, so I changed the first line from: $(document.body).click(function(){ to $(document.body).click(function(event){ Gotta tell ya, when I hear the phrase "event delegation" my head starts to hur

[jQuery] Re: Capture a click outside of a specific object?

2009-01-13 Thread Kean
You might want to look at live and die method now posted in jQuery documentation. On Jan 13, 11:32 am, riotbrrd wrote: > Hi all, > > Is there a simple way to capture a click event in a window/document > and then determine whether the click was inside an element #foo, or > outside of that element

[jQuery] Re: Capture a click outside of a specific object?

2009-01-13 Thread sam
What you're describing is a pattern called "event delegation." It is actually quite efficient, since you don't have to bind an event to each object, but rather 1 event to a larger object: $(document.body).click(function(){ var target = $(event.target); if (target.is("#foo")){ //it