单击后退和前进按钮时,rails和javascript两次触发

时间:2017-08-31 05:05:28

标签: javascript ruby-on-rails

如何在单击后退和前进按钮时停止rails和javascript执行两次此图像src?

Rails代码 - application.html.erb

<%= javascript_include_tag 'application', 'data-turbolinks-track': 
'reload' %>**  

js code - aa.js

 $(document).on('turbolinks:before-cache', function(event) {
 console.log("aastik");
 var scp = document.createElement('script');
 scp.setAttribute('src',''); //image https:// src
 scp.async = true;
 document.head.appendChild(scp);    
 });

rails - secure.html.erb

<span id="siteseal">
<script async type="text/javascript"
 src="/javascripts/aa.js">
</script>
</span>

0 个答案:

没有答案