I''ve beaten my head against the wall long enough. I started using
prototype in the last month, and it''s great. I''m just getting
along
w/ Event.observe and I''m running into an issue that I can''t
get past.
I don''t know if I''m doing it in the best way, and
it''s a problem that
I''m sure plenty of others have encountered and solved so thought
I''d
post here.
I''m trying to get a drop down menu to appear when a span is clicked
on and get it to disappear whenever anything else but the div that
appeared is clicked on, here''s my attempt
<span
onclick="toggle_and_observe(''menu'')">Drop
Down</span>
<div id=''menu''>some menu items</div>
and in my .js
function toggle_and_observe(elemId) {
$(elemId).toggle();
if($(elem).visible()) {
Event.observe(document.body, ''click'', function(event) {
var element = Event.element(event);
if ($(elemId) != element) {
$(elemId).hide();
}
})
}
}
I had to pull the toggle out and add it to the span to get that part
to work, but the event handling is definitely not working:
<span onclick="Element.toggle(''menu'');return
false;toggle_and_observe(''menu'')">Drop
Down</span>
I know it''s all hacky, perhaps a group member can point me to
information or offer a suggestion, thanks.
Tom Hartwell
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---