I would like to make an entire table row clickable so the user will be directed to another url. If i was using hand written javascript i would just add an onclick to the <tr>, but i want to use rails routes and to be able to pass in parameters from ruby. What is the best way to accomplish this? <tr onclick = <%= link_to my_route_path %> > <td>content</td></tr> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
I think you can make it done by jQuery or Prototype with CSS Selector:
<tr class="clickable" rel="<%= my_route_path
%>"><td>content</td></tr>
<script>
(function($){
$(''tr.clickable'').click(function(){ // You can use
.live(''click'',
function(){}) if you use jQuery 1.3.1 or higher
// Link to ...
});
})(jQuery);
</script>
On 4月1日, 下午12時39分, Richard Schneeman <rails-mailing-l...@andreas-
s.net> wrote:> I would like to make an entire table row clickable so the user will be
> directed to another url. If i was using hand written javascript i would
> just add an onclick to the <tr>, but i want to use rails routes and
to
> be able to pass in parameters from ruby. What is the best way to
> accomplish this?
>
> <tr onclick = <%= link_to my_route_path %> >
<td>content</td></tr>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
Richard Schneeman wrote:> I would like to make an entire table row clickable so the user will be > directed to another url. If i was using hand written javascript i would > just add an onclick to the <tr>, but i want to use rails routes and to > be able to pass in parameters from ruby. What is the best way to > accomplish this? > > <tr onclick = <%= link_to my_route_path %> > <td>content</td></tr>onclick="window.location.href = ''<%= url_for :controller => '':foo'' :action => ''bar'' %>'' see: http://api.rubyonrails.org/ see: http://api.rubyonrails.org/classes/ActionController/Base.html#M000624 D. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, both work great! Though i guess neither would degrade well with javascript turned off. Guess you cant have your clickable-rows and eat them too ^_^ -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---