【发布时间】:2011-02-25 21:59:46
【问题描述】:
我没有使用 ajax 调用,而是创建页面并将其注入到 $.mobile.pageContainer 中。 Dynamically creating jQuery Mobile pages using jQuery Templates
当我想访问带有井号标签(在我的 onReady 函数中生成的标签)的页面时,jQuery mobile 会尝试进行 ajax 调用。它失败。当我的 onReady 函数被调用时,我必须检查 url 并调用 $.mobile.changePage() 使其显示出来。
var loc = window.location.href;
var loc = loc.split('#').pop();
if (loc !== "http://lift.pageforest.com/") {
$.mobile.changePage(loc, 'pop', false, true);
}
这一切都很好,但是 jQuery Mobile 仍然进行了失败的 ajax 调用,从而导致向控制台抛出错误以及向用户显示一个大错误 div。
我尝试将 $.mobileinit 函数 ajaxEnabled() 覆盖为 false,因为我永远不会使用 ajax。 http://jquerymobile.com/demos/1.0a3/#docs/api/globalconfig.html 不幸的是,这带来了一大堆其他问题。
为什么jQuery mobile会自动假定我要使用ajax,而我自己的onReady函数不会生成任何内容?我该如何解决这个问题?
从这里转贴: http://forum.jquery.com/topic/how-to-disable-automatic-ajax-calls-when-dynamically-creating-pages
【问题讨论】:
-
你的页面有演示吗?
标签: jquery ajax jquery-mobile dynamic