当我在rails中使用link_to帮助器时,加载JavaScript时遇到了一些麻烦。当我手动输入带有'localhost:3000 / products / new'的URL或重新加载页面时,将加载javascript,但是当我经过如下所示的链接时,jQuery$(document).ready
将不会加载到新页面上。
Link_to,当我单击此链接时,javascript无法加载:
<%= link_to "New Product", new_product_path %>
products.js文件
$(document).ready(function() {
alert("test");
});
任何帮助将非常感激。提前致谢!