ご閲覧いただき、ありがとうございます。
Rails 5.2.2
で開発をしているのですが、最初にロードした際に正しくJSが読み込まれず、リロードすると正常に戻るというバグが生じています。
おそらく、Turbolinkあたりが悪さをしているように思うのですが、もし最適な解決策をご存知の方がいらっしゃればご教示お願いできませんでしょうか?
application.html.erb
ruby
1・・・ 2 <!-- Optional JavaScript --> 3 <!-- jQuery first, then Popper.js, then Bootstrap JS --> 4 <script 5 src="https://code.jquery.com/jquery-3.3.1.slim.min.js" 6 integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 7 crossorigin="anonymous" 8 ></script> 9 <script 10 src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" 11 integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" 12 crossorigin="anonymous" 13 ></script> 14 <script 15 src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" 16 integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" 17 crossorigin="anonymous" 18 ></script> 19 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 20</html>
application.js
ruby
1// This is a manifest file that'll be compiled into application.js, which will include all the files 2// listed below. 3// 4// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's 5// vendor/assets/javascripts directory can be referenced here using a relative path. 6// 7// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8// compiled file. JavaScript code in this file should be added after the last require_* statement. 9// 10// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11// about supported directives. 12// 13//= require rails-ujs 14//= require activestorage 15//= require turbolinks 16//= require_tree .
gemではなく、CDNでjQueryを読み込んでいるのが問題なのでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/27 20:45