javascript - Clickable Table Rows in Ruby on Rails -


just getting started rails , trying create clickable table rows in rails using bootstrap tables. have managed this, there seems problem when click on row through show page, press button on page return index view, clickable rows not work anymore. need refresh page work again.

i have taken @ rails 3 - how make entire table row clickable using jquery along other answers on site. still not seem work.

my code follows

index page

<tr data-link="<%= source_path(source) %>">         <td><%= source.name %></td>         <td><%= source.description %></td>         <td><%= link_to truncate(source.url, :length => 40), source.url, :target => '_blank' %></td>         <td><%= source.category %></td>         <td><%= source.user.name if source.user %></td>       </tr> 

application.js

jquery(function($) { $("tr[data-link]").click(function() { window.location = this.dataset.link }); }) 

try using jquery data() method

jquery(function($) {      $("tr[data-link]").click(function() {         window.location = $(this).data('link');     });  }); 

i don;t know why yours isn't working. perhaps have errors thrown in browser console


Popular posts from this blog