Hi all, is there a Rails way to associate an onclick event to a HTML element and invoke a controller''s action? <tr onclick="controller/action"> ... </tr> I have a table, and I want to show some info when user click on a row. Any better idea to achieve this one? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
> -----Original Message----- > From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of > Eduardo Yáñez Parareda > Sent: Wednesday, September 06, 2006 10:11 AM > To: Ruby on Rails: Talk > Subject: [Rails] onclick => :action ? > > > > Hi all, is there a Rails way to associate an onclick event to > a HTML element and invoke a controller''s action? > > <tr onclick="controller/action"> > ... > </tr> > > I have a table, and I want to show some info when user click > on a row. Any better idea to achieve > this one?<th onClick="window.location.href = ''<%= url_for :controller => ''foo'', :action => ''bar'' %>''"> Will that work for you? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hi Eduardo, Eduardo Yáñez Parareda wrote:> is there a Rails way to associate an onclick event to a HTML > element and invoke a controller''s action? > > <tr onclick="controller/action">I could be wrong and don''t have the time to verify this at the moment, but I believe that if you check the W3C spec you''ll find that events can only be assigned to controls. AFAIK, a table (nor its component elements) is not a control. I think you''ll need to use a link or button field as content of one of the table''s cells. For those, check the link_to and button_to documentation at http://api.rubyonrails.org hth, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---