Oh, it's really simple:

document.observe('click', function(e) {
  // traverse up looking for element that matches selector [1]
  if (e.target.up('#menu')) {
    hide('all');
  }
})

[1] http://www.prototypejs.org/api/element/up

- kangax

On Apr 15, 10:03 am, Ian <[EMAIL PROTECTED]> wrote:
> Hi,  I'm trying to convert some jquery code to Prototype.  Basically I
> want a click anywhere in the document other than the menu to close any
> open menu windows.
>
> in jQuery, it's this:
>
>         $(document).click(function(event){
>                         var target = $(event.target);
>                         if (target.parents("#menu").length == 0) {
>                                 hide('all');
>                         }
>         });
>
> in Prototype, I have this:
>
>         Element.observe(document, 'click', doThis);
>         function doThis(event){
>                 var target = $(event.target);
>                 alert(target);
>         }
>
> But how do I access the id and/or parent of the target element, so I
> can determine whether or not to close the menu windows?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to