Turbolinks导致带有href =“"#“的链接.触发页面刷新 [英] Turbolinks causes a link with href="#" to trigger page refresh
问题描述
我的页面上有一个非常简单的链接. <a href="#">My link</a>
.它导致页面刷新.当我删除"turbolinks"时,它不再引起刷新.
I have a very simple link on my page. <a href="#">My link</a>
. It causes a page refresh. when I remove "turbolinks", it no longer causes a refresh.
过去,我一直在使用带有哈希片段的链接.除非我长期错过了一些非常基础的东西,否则我不明白这会如何引起刷新.
I've used links with hash fragments all the time in the past. Unless I've missed something very fundamental for a long time, I don't understand how this can cause a refresh.
它没有附加任何JS事件处理程序.
It does not have any JS event handlers attached to it.
有什么想法吗?
可能没关系,但是我正在使用jQuery,Twitter-Bootstrap和Ruby on Rails.
It may not matter, but I'm using jQuery, Twitter-Bootstrap, and Ruby on Rails.
目前为止的线索:
- 当我删除Turbolinks时,链接表现正常(不会导致页面刷新).
- 以#"作为URL的链接会在我的应用程序的每个页面上重新加载.
- 与任何"#hasfragmenttext"的链接都将导致一次刷新,然后页面的URL为"mypage#hasfragmenttext",任何其他点击都不会导致页面刷新...嗯.
推荐答案
在该链接上使用data-no-turbolink
属性,错误应消失
Use data-no-turbolink
attribute on that link the error should be gone
<a href="#" data-no-turbolink>My link</a>
这篇关于Turbolinks导致带有href =“"#“的链接.触发页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!