I have a custom js file in app/assets/javascripts . This is the js file:
//app/assets/javascripts/contacts.js //$(document).ready(function() { //I've already tried with this method $(window).load(function() { alert("foo bar") });
I need the contacts.js file in the application.js file.
If I check the html page, I see that the js file is loaded correctly, but the message does not appear. If I reload the page (by pressing f5), the message will be displayed correctly.
When the page loads, javascript loads (I can see it in the HTML source code in the browser), but it didn’t execute.
Could you help me?
SOLUTION: Rails 4: how to use $ (document) .ready () with turbo links
source share