[英]Window.onload not getting called [Ruby on Rails] [Vanilla Javascript]
I have a Ruby on Rails Application, with application.html.erb
with the following body structure. 我有一个Ruby on Rails应用程序,其中
application.html.erb
具有以下主体结构。
<Header>
<anchor tags></anchor tags>
</Header>
<%= yield %>
On clicking the anchor tags in the header -> the content of the yield changes. 单击标题中的锚标记->产量的内容会更改。 But the
window.onload
only loads one time ie when the page loads for the first time, despite navigating through the anchor tags in the header. 但是
window.onload
只加载一次,即页面第一次加载时,尽管浏览了标题中的anchor标签。 Due to which all the bindings and events which were handled inside the window.onload
are getting lost. 因此,在
window.onload
内部处理的所有绑定和事件都将丢失。
How to add the same bindings and events when window.load is not getting called OR any alternative to window.onload
using vanilla javascript that can solve the problem? 当未调用window.load或使用可解决问题的香草javascript替代
window.onload
时,如何添加相同的绑定和事件?
A possible reason for this behavior is turbolink gem. 出现这种情况的可能原因是turbolink gem。 Try to remove it if You haven't done it already.
如果尚未删除它,请尝试将其删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.