jQuery 仅限移动版菜单

jQuery Mobile only for the menu

我正在构建一个移动网站,我想实现 jQuery 数据角色和其他仅在菜单上的有用功能。

是否可以调整 jQuery 库使其仅在菜单上工作而保留所有其他网站导航 "normal"?

您必须在 jQuery 移动配置文件或 HTML 文件的头部设置选项 $.mobile.ignoreContentEnabled = true - 此选项应在加载 JQM 之前设置:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
$(document).on('mobileinit', function () {
    $.mobile.ignoreContentEnabled = true;
});
</script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

然后,您可以将 rel=external 放在锚标记中 - link 将在没有 ajax 的情况下加载,而您的 url 将 "navigate normal":

<a href="http://whosebug.com" rel="external" />Link without ajax</a>

在这里您可以找到关于这个主题的 JQM 文档:

https://demos.jquerymobile.com/1.4.5/navigation-linking-pages/