jQuery Mobile 页面导航

发布于 2024-10-09 09:47:07 字数 220 浏览 0 评论 0原文

我的网络项目中有 4 个页面,分别是 a、b、c 和d.每个页面的顶部都有一个选项卡栏/导航栏和相互链接的按钮。导航功能完美。 但是,我想执行一些操作,例如单击 b 时 - 将从数据库中获取一些数据,单击 c 时更新数据等。然而,所有这些 javascript 函数都在第一页上工作,该页面在执行 Web 应用程序时启动。如果我导航到其他页面,该页面上的 js 将不起作用。我们不能一次性绑定所有这些按钮吗? 请建议。 谢谢。

I've 4 pages in my web project say a,b,c & d. Each page has a tab-bar/navigation bar at top and buttons which are and linked to each other. The navigation works perfect.
However, I want to perform some actions like, when b is clicked - some data will be fetched from database, when c is clicked data is updated and likewise. However, all these javascript functions works on first page which gets started when web-app is executed. If I navigate to other pages, js on that page doesn't work. Can't we have once for all binding to all these buttons?
Please suggest.
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…楫夜泊 2024-10-16 09:47:07

默认情况下,jquerymobile 将尝试使用 Ajax 检索页面内容并添加到当前页面 DOM,而不是普通的页面请求。您可以尝试以下选项:
1.使用$.mobile.changePage()
2. 使用 mobileinit 事件(在 jquerymobile js 加载之前)更改默认行为:
$(document).bind("mobileinit", function () {
$.mobile.ajaxEnabled = false; //默认不通过ajax处理链接
});

jquerymobile will try to use Ajax to retrieve page content and add to current page DOM instead of normal page request by default. You may try following options:
1. Use $.mobile.changePage()
2. Use mobileinit event (before jquerymobile js loaded) to change the default behavior:
$(document).bind("mobileinit", function () {
$.mobile.ajaxEnabled = false; //do not handle links via ajax by default
});

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文