title: Clickable Table Rows in Ruby on Rails
body: <p>Just getting started with Rails and I am trying to create clickable table rows in Rails using bootstrap tables. I have managed to do this, however there seems to be a problem where when I click on the row through to the show page, then press the back button on that page to return to the index view, the clickable rows do not work anymore. I need to refresh the page to get it to work again. </p>
  
  <p>I have taken a look at <a href="https://stackoverflow.com/questions/20036251/rails-3-how-to-make-entire-table-row-clickable-using-jquery">Rails 3 - How to make entire table row clickable using jQuery</a> along with other answers on the site. Still does not seem to work.</p>
  
  <p>My code is as follows</p>
  
  <p>Index Page</p>
  
  <pre><code>&lt;tr data-link="&lt;%= source_path(source) %&gt;"&gt;
          &lt;td&gt;&lt;%= source.name %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= source.description %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to truncate(source.url, :length =&gt; 40), source.url, :target =&gt; '_blank' %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= source.category %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= source.user.name if source.user %&gt;&lt;/td&gt;
        &lt;/tr&gt;
  </code></pre>
  
  <p>application.js</p>
  
  <pre><code>jQuery(function($) {
  $("tr[data-link]").click(function() {
  window.location = this.dataset.link
  });
  })
  </code></pre>