[Proto-Scripty] Re: Prototype - Close div when click off?

2010-09-21 Thread T.J. Crowder
Hi, TJ, you inadvertently disabled Edit using JS Bin for this example :) LOL! You're right! Just add /edit to the URL. Who is JS Bin, is that yours?  Very cool. Not mine, and in fact it drives me nuts, the editor is always getting in your way. But yes, it's a very handy way to do live

[Proto-Scripty] Re: Prototype - Close div when click off?

2010-09-21 Thread T.J. Crowder
Hi, I want the div to close when the user clicks on anything BUT the div. Well, we can't do that with delegation, because the elements themselves may have click handlers or default behaviors that would happen before the click bubbled up to the document body. You *could* do that by setting an

[Proto-Scripty] Re: Prototype - Close div when click off?

2010-09-21 Thread T.J. Crowder
Hi, Actually, sorry, in the quoted code change this: if (this.id != 'the_ID_of_your_special_div') { to if (!event.findElement(#the_ID_of_your_special_div)) { ...to ensure that clicks on child elements of your special div are handled correctly. Here's the updated JSBin:

[Proto-Scripty] Re: Prototype - Close div when click off?

2010-09-20 Thread T.J. Crowder
Hi, Not entirely sure what you're trying to do, but this will fail: $(document.body).descendants().observe ^-- Problem here `#observe` is a function Prototype adds to *elements*, not arrays. `#descendants` returns an array. Although you could fix this via

[Proto-Scripty] Re: Prototype - Close div when click off?

2010-09-20 Thread kstubs
TJ, you inadvertently disabled Edit using JS Bin for this example :) Who is JS Bin, is that yours? Very cool. On Sep 20, 5:12 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Not entirely sure what you're trying to do, but this will fail:     $(document.body).descendants().observe    

[Proto-Scripty] Re: Prototype - Close div when click off?

2010-09-20 Thread Jason
Hi T.J. Sorry for being unclear. I want the div to close when the user clicks on anything BUT the div. What you have written makes sense with the findElement. Can findElement by used to literally find any element and then compare it to find out if it is a child or parent of the relevant div.

Re: [Proto-Scripty] Re: Prototype - Close div when click off?

2010-09-20 Thread Walter Lee Davis
I like to think of Event#findElement as the equivalent of the XPath expression self-or-ancestor. I use it a lot for delegated observers, like placing one click listener on a common parent element, then using $('parentElement').observe('click', function(evt){ if