Why is link_to in Rails not invoking javascripts for the linked page?

52 Views Asked by At

I have a link_to on my page and when I click on it, it takes me to the correct page, but no javascript gets executed. When I refresh the page, it works fine. How do I fix this so that link_to actually makes a new request to the server?

Thanks

1

There are 1 best solutions below

3
On BEST ANSWER

You need to make your link remote so it executes your ajax request.

An example of it would be as follows:

<%= link_to my_path, method: :post, :remote => true do %>
  <i class="icon-update"></i>
<% end %>

Please post more information about your code in case this doesn't solve your problem.