javascript - jquery 3 document ready is blocking turbolinks from executing -
i using jquery 1.12.4 far , ok, had :
$(document).ready -> console.log "document ready yaay!" start = -> alert "hello world!!!" document.addeventlistener('turbolinks:load', start) i upgraded rails 5.1 yesterday , decided add , upgrade jquery (yep still need it) installed jquery 3 using yarn, same code above doesn't executed, @ least turbolinks part (the console.log executed every time document loaded "start" method not)
i removed $(document).ready -> , code start working expected !!!
to make sure removed jquery 3 , installed jquery 1.12 , worked! $(document).ready ->
why happening ?
make sure add //= require jquery application.js file.
in command line, run yarn install jquery lower case
here application.js file 1 of project using jquery through yarn.
//= require rails-ujs //= require turbolinks //= require jquery //= require_tree . edit: if want console.log , alert fire @ every page change. can write javascript this.
$(document).on('turbolinks:load', function() { console.log('test'); alert("hello world!!!"); });
Comments
Post a Comment