问题描述
Jquery Mobile 已决定将锚链接视为某种页面请求.但是,如果您有大量的博客文章具有指向同一页面的锚链接(即 href="#specs"),这就不好了.
Jquery Mobile has decided to treat anchor links as page requests of sort. However, this isn't good if you have a load of blog posts which have anchor links to the same page (ie href="#specs").
有没有办法在特定页面上禁用 jquery mobile 的锚链接使用,我知道我不会在该页面上使用它,所以我可以按预期使用锚链接,下拉到页面的一部分?
Is there a way to disable jquery mobile's anchor link usage on a specific page which I know I won't be using it on so I can use anchor links as they were intended, to drop down to a part of the page?
我只需要针对同一页面上的锚链接的解决方案(即:href="#specs").
I only need a solution for anchor links on the same page (ie: href="#specs").
谢谢
推荐答案
您可以尝试在锚标记上添加 data-ajax="false"
.
You could try adding a data-ajax="false"
on the anchor tag.
没有 Ajax 的链接
指向其他域或具有 rel="external" 的链接,data-ajax="false" 或目标属性将不会与 Ajax 一起加载.相反,这些链接将导致没有动画的整页刷新过渡.两个属性(rel="external" 和 data-ajax="false")效果相同,但语义不同:rel="external"链接到另一个站点或域时应使用,而data-ajax="false" 对于简单地选择一个页面很有用域通过 Ajax 加载.由于安全限制,框架总是选择链接到 Ajax 之外的外部域行为.
Links that point to other domains or that have rel="external", data-ajax="false" or target attributes will not be loaded with Ajax. Instead, these links will cause a full page refresh with no animated transition. Both attributes (rel="external" and data-ajax="false") have the same effect, but a different semantic meaning: rel="external" should be used when linking to another site or domain, while data-ajax="false" is useful for simply opting a page within your domain from being loaded via Ajax. Because of security restrictions, the framework always opts links to external domains out of the Ajax behavior.
参考 - http://jquerymobile.com/demos/1.0.1/docs/pages/page-links.html
这篇关于如何让锚链接在 Jquery Mobile 中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!