Jquery 加载包含多个数据部分的外部文件

Jquery 加载包含多个数据部分的外部文件,jquery,jquery-mobile,Jquery,Jquery Mobile,我想知道如何加载一个包含一个页面和多个对话框的外部页面 //I am in index.htm, a multi-page file which will send a big object to anotherpage.htm $.mobile.changePage(anotherPage.htm, {type:"post",data:formData}) 这将使post变得很好,并传入formData。但是,anotherPage.htm中的对话框不可用。如果我直接访问另一个page.ht

我想知道如何加载一个包含一个页面和多个对话框的外部页面

//I am in index.htm, a multi-page file which will send a big object to anotherpage.htm
$.mobile.changePage(anotherPage.htm, {type:"post",data:formData})
这将使post变得很好,并传入formData。但是,anotherPage.htm中的对话框不可用。如果我直接访问另一个page.htm,页面将按预期运行。jQM仅在另一个page.htm中找到的第一个页面中加载

//anotherpage.htm
<div data-role="page" id="mypage">
     <p id="something">Some thing</p>
    <script>
  //bind to the pageinit event to fire the email handling.
   $("#something").live("click", function() {
        $.mobile.changePage('#successDialog',{ transition: "pop", role: "dialog", reverse: false });
   });

</script>
</div>
<div data-role="dialog" id="successDialog" >
    <p>Success!</p>
</div>
<div data-role="dialog" id="failureDialog" >
    <p>Failure!</p>
    <a id="dialogClose" href="#" data-rel="back" data-role="button">Close</a>
</div>
//anotherpage.htm

某物

//绑定到pageinit事件以触发电子邮件处理。 $(“#某物”).live(“单击”,函数(){ $.mobile.changePage(“#successDialog”,{转换:“pop”,角色:“dialog”,反向:false}); }); 成功

失败


不幸的是,当您使用ajax加载多页模板时,它只会拉入您请求的页面,您将不得不将对话框分离成单独的文件,或者使用相同的页面和散列页面id引用这些对话框

我想我在尝试传统提交而不是更改页面时是正确的。我没有做的是将数据对象正确地附加到submit中,如图所示。