andleer是正確的「的任何頁面可以通過添加data-rel="dialog"
屬性頁面錨鏈接被呈現爲模態對話框」,不使用與JQM切換(),它是不需要。創建jQM對話框用作分隔頁面。看看這個例子:
<div data-role="page" id="index">
<div data-theme="a" data-role="header">
<h3>
First Page
</h3>
<a href="#second" class="ui-btn-right">Next</a>
</div>
<div data-role="content">
<a href="#" data-role="button" id="open-button">Open dialo</a>
</div>
<div data-theme="a" data-role="footer" data-position="fixed">
</div>
</div>
<!-- DIALOG BOX -->
<div data-role="page" id="dialog-box" data-theme="b">
<div data-role="header">
<h1>Warning</h1>
</div>
<div data-role="content">
<h3 id="dialog-msg">
Dialog test
</h3>
<a href="#" data-role="button" id="close-button">
Close dialog
</a>
</div>
</div>
此外,如果可能,你應該打開對話框如下:
$.mobile.changePage('#dialog-box', {transition: 'pop', role: 'dialog'});
如果你是動態變化的對話框的內容,您必須觸發pagecreate它來正確restyle它:
$('#dialog-box').trigger("pagecreate");
這裏是一個完整的jsfiddle例如:http://jsfiddle.net/Gajotres/fXzWj/
感謝您的回覆和時間,我會試一試。 –
謝謝,您的解決方案幫助我瞭解JQM頁面的動態。非常感謝。 :) –