I would like for several links (<a> tags w/ onclick events) to be automatically clicked (to refresh data) after a secondary affecting value has been changed. So I would like to do something like: $$(''selectors'').each(click()) OR $$(''selectors'').each().click() But no matter how I rewrite it, it doesn''t seem to work. I''m not getting any javascript errors either, so I''m a little confused. Any ideas? Thanks in advance! --Josh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 17.8.2007, at 9.17, Josh Carroll wrote:> > I would like for several links (<a> tags w/ onclick events) to be > automatically clicked (to refresh data) after a secondary affecting > value has been changed. So I would like to do something like: > > $$(''selectors'').each(click()) > > OR > > $$(''selectors'').each().click()You''d have to do something like $$(''selectors'').each(function(e) { e.click(); }); (see http://prototypejs.org/api/enumerable/each) However, there is an easier way: $$(''selectors'').invoke(''click''); http://prototypejs.org/api/enumerable/invoke By the way, this is one of the items in the recently posted "How well do you know prototype" list (http://thinkweb2.com/projects/prototype- checklist/). Highly recommended. Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
Sweet! Thanks! I just realized that my larger problem was that you can''t invoke click on <a> tags (unless I''m missing something). I changed those to buttons, and now it''s working like a champ! Thanks again! I''ll read that list. --Josh On Aug 17, 2007, at 2:31 AM, Jarkko Laine wrote:> On 17.8.2007, at 9.17, Josh Carroll wrote: > >> >> I would like for several links (<a> tags w/ onclick events) to be >> automatically clicked (to refresh data) after a secondary affecting >> value has been changed. So I would like to do something like: >> >> $$(''selectors'').each(click()) >> >> OR >> >> $$(''selectors'').each().click() > > You''d have to do something like > > $$(''selectors'').each(function(e) { > e.click(); > }); > > (see http://prototypejs.org/api/enumerable/each) > > However, there is an easier way: > > $$(''selectors'').invoke(''click''); > > http://prototypejs.org/api/enumerable/invoke > > By the way, this is one of the items in the recently posted "How > well do you know prototype" list (http://thinkweb2.com/projects/ > prototype-checklist/). Highly recommended. > > Cheers, > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Josh, Invoking click() on an element works for you? I''m quite confused here, because there''s no such method in prototype, afaik. If we''re talking about creating custom event, then the proper way to do this (as of 1.6) is by callnig fire() on an element $(''elementId'').fire(''click''); // simulates click event on an element $$(''a'').invoke(''fire'', ''click'') // simulates click event on all elements these events should essentially trigger your observers (if any) -- View this message in context: http://www.nabble.com/using-%24%24%28%29-each%28%29-and-click%28%29-together-tf4283891.html#a12204393 Sent from the RubyOnRails Spinoffs mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Aug 17, 2007, at 1:57 PM, kangax wrote:> $(''elementId'').fire(''click''); // simulates click event on an elementWhat version of prototype includes fire()? I was looking for something like that last night (same problem as the OP) and couldn''t find it. I arrived at the same solution, and it worked just fine. I see fire in the latest RC, but what about the current stable? Walter --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
there''s no fire() prior to 1.6 everybody was using 3rd party extensions current RC is pretty stable... you should give it a spin -- View this message in context: http://www.nabble.com/using-%24%24%28%29-each%28%29-and-click%28%29-together-tf4283891.html#a12205033 Sent from the RubyOnRails Spinoffs mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes, using $$(''selectors'').invoke(''click'') works in the latest releases of Firefox and Safari for Mac anyway, as long as the targets designated by $$(''selectors'') are buttons. I haven''t tested in any Windows browsers just yet. I will try using $$(''selectors'').invoke(''fire'',''click'') if this gives me any issues. --Josh On Aug 17, 2007, at 12:57 PM, kangax wrote:> > > Josh, > > Invoking click() on an element works for you? > I''m quite confused here, because there''s no such method in > prototype, afaik. > If we''re talking about creating custom event, then the proper way > to do this > (as of 1.6) is by callnig fire() on an element > > $(''elementId'').fire(''click''); // simulates click event on an element > > $$(''a'').invoke(''fire'', ''click'') // simulates click event on all > elements > > these events should essentially trigger your observers (if any) > > -- > View this message in context: http://www.nabble.com/using-%24%24%28% > 29-each%28%29-and-click%28%29-together-tf4283891.html#a12204393 > Sent from the RubyOnRails Spinoffs mailing list archive at Nabble.com. > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---