7

I want to make <tr> clickable with code like this:

<tr <%= link_to 'Show', show_account_employees_path(account), :remote => true %>>

I found solution only for direct link without remote.

Thanks for help!

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
yaartem
  • 147
  • 1
  • 6

1 Answers1

6

Referring to your comment I need all row be clickable

You can't have a tr inside an anchor tag. It's invalid HTML to have any elements other than thead,tbody as a direct child of a table. You'll have to place your anchor tag inside a td or th to be valid.

FIX

If you want entire row to be clickable then you'll have to use js magic, you can do something like:

Use HTML5 data-attribute to get your link value

<tr data-href= "<%= show_account_employees_path(account) %>">
  <td></td>
</tr>

Don't know what exactly you are trying to accomplish by making an ajax request to show an employee but since you want it so you can make it an ajax request using jquery's ajax method

$(document).on("click", "#table-id tr", function() {
  var link  = $(this).data("href")
  $.ajax({
    url: link,
    type: "GET"
  });
});
Mandeep
  • 9,093
  • 2
  • 26
  • 36