Hi all, I''am new to Prototype and after a 2 hours of research I didn''t find a solution for the following question: I have the following list: <ul id="navi"> <li><a href="/about/">Home</a></li> <li><a href="/about/" class="dropdown" onmouseover="showSubnavi(this)">About</a> <ul style="display:none;"> <li><a href="/history/">History</a></li> <li><a href="/facts/">Facts</a></li> <li><a href="/partners/">Partners</a></li> <li><a href="/team/">Team</a></li> </ul> </li> etc.... </ul> What id like to do: Replace the HTML-Attribute onmouseover="showSubnavi(this)" using the prototype Event.observe. All links with the class "dropdown" should be observed for onmouseover events and execute the function showSubnavi(this) - the ''this'' argument shouldn''t be lost and i think thats the tricky part. Im sure the soultion includes something with bindAsEventListener, but I didn''t really get that. Thank you alot! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It''s going to be something like this: $$(''a.dropdown'').each(function(elm){showSubnavi(elm)}); Wrap that in an observer to set it all up at page load, or simply add it to the bottom of the page in a script block. Walter On Mar 5, 2008, at 6:28 PM, Luke The Duke wrote:> > Hi all, > > I''am new to Prototype and after a 2 hours of research I didn''t find a > solution for the following question: > > I have the following list: > > <ul id="navi"> > <li><a href="/about/">Home</a></li> > <li><a href="/about/" class="dropdown" > onmouseover="showSubnavi(this)">About</a> > <ul style="display:none;"> > <li><a href="/history/">History</a></li> > <li><a href="/facts/">Facts</a></li> > <li><a href="/partners/">Partners</a></li> > <li><a href="/team/">Team</a></li> > </ul> > </li> > etc.... > </ul> > > What id like to do: Replace the HTML-Attribute > onmouseover="showSubnavi(this)" using the prototype Event.observe. All > links with the class "dropdown" should be observed for onmouseover > events and execute the function showSubnavi(this) - the ''this'' > argument shouldn''t be lost and i think thats the tricky part. > Im sure the soultion includes something with bindAsEventListener, but > I didn''t really get that. > > Thank you alot! > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for your answer, but this piece of code doesnt observe a function. On Mar 5, 7:28 pm, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> It''s going to be something like this: > > $$(''a.dropdown'').each(function(elm){showSubnavi(elm)}); > > Wrap that in an observer to set it all up at page load, or simply add > it to the bottom of the page in a script block. > > Walter > > On Mar 5, 2008, at 6:28 PM, Luke The Duke wrote: > > > > > Hi all, > > > I''am new to Prototype and after a 2 hours of research I didn''t find a > > solution for the following question: > > > I have the following list: > > > <ul id="navi"> > > <li><a href="/about/">Home</a></li> > > <li><a href="/about/" class="dropdown" > > onmouseover="showSubnavi(this)">About</a> > > <ul style="display:none;"> > > <li><a href="/history/">History</a></li> > > <li><a href="/facts/">Facts</a></li> > > <li><a href="/partners/">Partners</a></li> > > <li><a href="/team/">Team</a></li> > > </ul> > > </li> > > etc.... > > </ul> > > > What id like to do: Replace the HTML-Attribute > > onmouseover="showSubnavi(this)" using the prototype Event.observe. All > > links with the class "dropdown" should be observed for onmouseover > > events and execute the function showSubnavi(this) - the ''this'' > > argument shouldn''t be lost and i think thats the tricky part. > > Im sure the soultion includes something with bindAsEventListener, but > > I didn''t really get that. > > > Thank you alot!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This will probably work. $$("a.dropdown").invoke("observe", "mouseover", function() { showSubnav(this) }); -Nicolas On Wed, Mar 5, 2008 at 9:28 PM, Luke The Duke <razigal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all, > > I''am new to Prototype and after a 2 hours of research I didn''t find a > solution for the following question: > > I have the following list: > > <ul id="navi"> > <li><a href="/about/">Home</a></li> > <li><a href="/about/" class="dropdown" > onmouseover="showSubnavi(this)">About</a> > <ul style="display:none;"> > <li><a href="/history/">History</a></li> > <li><a href="/facts/">Facts</a></li> > <li><a href="/partners/">Partners</a></li> > <li><a href="/team/">Team</a></li> > </ul> > </li> > etc.... > </ul> > > What id like to do: Replace the HTML-Attribute > onmouseover="showSubnavi(this)" using the prototype Event.observe. All > links with the class "dropdown" should be observed for onmouseover > events and execute the function showSubnavi(this) - the ''this'' > argument shouldn''t be lost and i think thats the tricky part. > Im sure the soultion includes something with bindAsEventListener, but > I didn''t really get that. > > Thank you alot! > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Nicolas Thanks for your answer. I also tried this, but It doesnt work because ''this'' argument isnt supported in this manner when observing functions. On Mar 5, 8:40 pm, "Nicolás Sanguinetti" <godf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This will probably work. > > $$("a.dropdown").invoke("observe", "mouseover", function() { > showSubnav(this) }); > > -Nicolas > > On Wed, Mar 5, 2008 at 9:28 PM, Luke The Duke <razi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi all, > > > I''am new to Prototype and after a 2 hours of research I didn''t find a > > solution for the following question: > > > I have the following list: > > > <ul id="navi"> > > <li><a href="/about/">Home</a></li> > > <li><a href="/about/" class="dropdown" > > onmouseover="showSubnavi(this)">About</a> > > <ul style="display:none;"> > > <li><a href="/history/">History</a></li> > > <li><a href="/facts/">Facts</a></li> > > <li><a href="/partners/">Partners</a></li> > > <li><a href="/team/">Team</a></li> > > </ul> > > </li> > > etc.... > > </ul> > > > What id like to do: Replace the HTML-Attribute > > onmouseover="showSubnavi(this)" using the prototype Event.observe. All > > links with the class "dropdown" should be observed for onmouseover > > events and execute the function showSubnavi(this) - the ''this'' > > argument shouldn''t be lost and i think thats the tricky part. > > Im sure the soultion includes something with bindAsEventListener, but > > I didn''t really get that. > > > Thank you alot!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What do you mean "this isn''t supported"? Inside an event handler, using Prototype 1.6, this references the node that fired the event, in your case the <a class="dropdown"> Best, -Nicolas On Thu, Mar 6, 2008 at 2:22 PM, Luke The Duke <razigal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Nicolas > > Thanks for your answer. I also tried this, but It doesnt work because > ''this'' argument isnt supported in this manner when observing > functions. > > > On Mar 5, 8:40 pm, "Nicolás Sanguinetti" <godf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > This will probably work. > > > > $$("a.dropdown").invoke("observe", "mouseover", function() { > > showSubnav(this) }); > > > > -Nicolas > > > > > > On Wed, Mar 5, 2008 at 9:28 PM, Luke The Duke <razi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Hi all, > > > > > I''am new to Prototype and after a 2 hours of research I didn''t find a > > > solution for the following question: > > > > > I have the following list: > > > > > <ul id="navi"> > > > <li><a href="/about/">Home</a></li> > > > <li><a href="/about/" class="dropdown" > > > onmouseover="showSubnavi(this)">About</a> > > > <ul style="display:none;"> > > > <li><a href="/history/">History</a></li> > > > <li><a href="/facts/">Facts</a></li> > > > <li><a href="/partners/">Partners</a></li> > > > <li><a href="/team/">Team</a></li> > > > </ul> > > > </li> > > > etc.... > > > </ul> > > > > > What id like to do: Replace the HTML-Attribute > > > onmouseover="showSubnavi(this)" using the prototype Event.observe. All > > > links with the class "dropdown" should be observed for onmouseover > > > events and execute the function showSubnavi(this) - the ''this'' > > > argument shouldn''t be lost and i think thats the tricky part. > > > Im sure the soultion includes something with bindAsEventListener, but > > > I didn''t really get that. > > > > > Thank you alot! > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
true! works fine. Thought I tried this. Thanks a lot man! On Mar 6, 1:11 pm, "Nicolás Sanguinetti" <godf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What do you mean "this isn''t supported"? Inside an event handler, > using Prototype 1.6, this references the node that fired the event, in > your case the <a class="dropdown"> > > Best, > -Nicolas > > On Thu, Mar 6, 2008 at 2:22 PM, Luke The Duke <razi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Nicolas > > > Thanks for your answer. I also tried this, but It doesnt work because > > ''this'' argument isnt supported in this manner when observing > > functions. > > > On Mar 5, 8:40 pm, "Nicolás Sanguinetti" <godf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > This will probably work. > > > > $$("a.dropdown").invoke("observe", "mouseover", function() { > > > showSubnav(this) }); > > > > -Nicolas > > > > On Wed, Mar 5, 2008 at 9:28 PM, Luke The Duke <razi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi all, > > > > > I''am new to Prototype and after a 2 hours of research I didn''t find a > > > > solution for the following question: > > > > > I have the following list: > > > > > <ul id="navi"> > > > > <li><a href="/about/">Home</a></li> > > > > <li><a href="/about/" class="dropdown" > > > > onmouseover="showSubnavi(this)">About</a> > > > > <ul style="display:none;"> > > > > <li><a href="/history/">History</a></li> > > > > <li><a href="/facts/">Facts</a></li> > > > > <li><a href="/partners/">Partners</a></li> > > > > <li><a href="/team/">Team</a></li> > > > > </ul> > > > > </li> > > > > etc.... > > > > </ul> > > > > > What id like to do: Replace the HTML-Attribute > > > > onmouseover="showSubnavi(this)" using the prototype Event.observe. All > > > > links with the class "dropdown" should be observed for onmouseover > > > > events and execute the function showSubnavi(this) - the ''this'' > > > > argument shouldn''t be lost and i think thats the tricky part. > > > > Im sure the soultion includes something with bindAsEventListener, but > > > > I didn''t really get that. > > > > > Thank you alot!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---