# Make a \<tr\>clickable

**URL:** <https://www.ruby-forum.com/t/make-a-tr-clickable/164414>\
**Category:** Rails\
**Created:** [April 1, 2009, 6:39am UTC](https://www.ruby-forum.com/t/make-a-tr-clickable/164414 "2009-04-01T06:39:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [April 1, 2009, 6:39am UTC](https://www.ruby-forum.com/t/make-a-tr-clickable/164414/1 "2009-04-01T06:39:28Z")

</div>

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

, 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? \> content

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [April 1, 2009, 10:00am UTC](https://www.ruby-forum.com/t/make-a-tr-clickable/164414/2 "2009-04-01T10:00:07Z")

</div>

Richard S. 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 , 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?
> 
> \> content

onclick="window.location.href = ‘\<%= url\_for :controller =\> ‘:foo’  
:action =\> ‘bar’ %\>’

see: [http://api.rubyonrails.org/](http://api.rubyonrails.org/)  
see:  
[ActionController::Base](http://api.rubyonrails.org/classes/ActionController/Base.html#M000624)

D.

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [April 1, 2009, 10:28am UTC](https://www.ruby-forum.com/t/make-a-tr-clickable/164414/3 "2009-04-01T10:28:15Z")

</div>

I think you can make it done by jQuery or Prototype with CSS Selector:

content

On 4æœˆ1æ—¥, ä¸‹åˆ12æ™‚39åˆ†, Richard S. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [April 9, 2009, 6:06am UTC](https://www.ruby-forum.com/t/make-a-tr-clickable/164414/4 "2009-04-09T06:06:23Z")

</div>

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 🙂
