简体   繁体   English

Rails 5 Turbolinks 似乎重新加载页面

[英]Rails 5 Turbolinks appears to reload page

I am still new to Turbolinks and unsure whether it is working correctly.我对 Turbolinks 还是个新手,不确定它是否正常工作。 I have a new rails app that I've created with Turbolinks enabled by default.我有一个新的 Rails 应用程序,我创建时默认启用了 Turbolinks。 I am using the link_to rails helper to build some links.我正在使用link_to rails helper 来构建一些链接。 When I click on one of the links the page reloads in the browser.当我单击其中一个链接时,页面会在浏览器中重新加载。 I was under the impression that this should not occur as only the body should be swapped using AJAX.我的印象是这不应该发生,因为只有身体应该使用 AJAX 交换。 Is there any additional attributes I need to add to my link or additional configuration I need to set up?是否有任何其他属性需要添加到我的链接或我需要设置的其他配置?

Make sure that you have the Turbolinks js loaded in the page.确保您在页面中加载了 Turbolinks js。 If you are using webpacker and removed the default application js that used the asset pipeline you will probably need to use Turbolinks from npm, import it and then call Turbolinks.start() in your entry file.如果您正在使用 webpacker 并删除了使用资产管道的默认应用程序 js,您可能需要使用 npm 中的 Turbolinks,导入它,然后在您的入口文件中调用Turbolinks.start()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM