Javascript Jquery mobile中的.mobile.loadPage和外部页面存在问题

Javascript Jquery mobile中的.mobile.loadPage和外部页面存在问题,javascript,jquery-mobile,Javascript,Jquery Mobile,在我的jquery移动应用程序中,我有一个页面需要加载外部内容 尝试遵循文档,我的代码不会产生任何脚本错误,但我的外部内容不会加载 $(document).ready(function () { $.mobile.ajaxEnabled = false; //Initialize page container per docs $("#staff-directory-container").pagecontainer({ default

在我的jquery移动应用程序中,我有一个页面需要加载外部内容

尝试遵循文档,我的代码不会产生任何脚本错误,但我的外部内容不会加载

    $(document).ready(function () {
        $.mobile.ajaxEnabled = false;

        //Initialize page container per docs 
        $("#staff-directory-container").pagecontainer({ defaults: true });

        //Get external content into DOM
        $.mobile.loadPage("http://another.domain.com/myContent.html", {
        pageContainer: $('#staff-directory-container')
            });

    });
提前感谢您提供的任何帮助。。。。
Chris

要在jQuery Mobile中绑定事件,请使用pagecreate,它相当于.ready。要加载外部页面,请使用as。loadPage已弃用,将在jQM 1.5中删除

在您的例子中,$.mobile.pageContainer是$staff目录容器。请注意,应该启用Ajax


Staff目录禁用ajax时,您不能使用.loadPage,因为它使用ajax获取HTML内容。Omar,我已将ajaxEnabled设置为true,但仍然没有加载外部页面,您是否看到任何其他缺失或错误的内容?使用$Staff-Directory-container.pagecontainerload,file.HTML;不要使用。准备好了。您想什么时候加载该页面?在哪个阶段?我想在按钮点击事件后加载该页面。Omar,谢谢,现在得到:错误:无法在初始化之前调用pagecontainer上的方法;尝试调用方法“load”下面的我的代码不会导致任何错误,但不会将内容加载到我的pagecontainer中:是的,我刚刚测试了@ChristopherCrisis我已经更新了我的答案。$document.onpagecreate,mobile index,function{//mobile index是带有按钮的页面,而不是pagecontainer$staff目录容器。pagecontainer{defaults:true};$get-staff-directory.onclick,函数{$staff-directory-container.pagecontainerload,;};}@ChristopherCrisis我已经测试了代码,它可以正常工作。你仍然有错误吗?
$(document).on("pagecreate", "#pageID", function () {
  $("#loadBtn").on("click", function () {
    /* define new pagecontainer then load */
    $.mobile.pageContainer = $("#staff-directory-container").pagecontainer();
    $.mobile.pageContainer.pagecontainer("load", "myContent.html");
  });
});