I'm having some trouble loading my javascript when I use a link_to helper in rails. When I either manually enter the url with 'localhost:3000/products/new' or reload the page, the javascript loads, but when I go through a link as written below, the jQuery $(document).ready
will not load on the new page.
Link_to, javascript does not load when I click this link:
<%= link_to "New Product", new_product_path %>
products.js file
$(document).ready(function() {
alert("test");
});
Any help would be much appreciated. Thanks in advance!
The solution that solved my issue was adding this meta property.
This ensures visits to a certain page will always trigger a full reload.
This was incredibly useful for working on a solution to solve the issue I was having with this, https://github.com/turbolinks/turbolinks#reloading-when-assets-change .