2013-01-07 50 views
1

我有我的jQuery手機頁面如下。它具有帶有文本字段和div的窗體,我需要在由java腳本提交表單後在同一頁面上顯示對話框(帶ID爲「dialog1」的div)。jquery mobile:從java腳本打開對話框中的頁面div

<!DOCTYPE html> 
<html> 
<head> 
    <title>title</title> 
    <meta charset="utf-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="/themes/site_theme/css/mobile.css" /> 
    <link rel="stylesheet" href="/themes/site_theme/css/jquery.mobile-1.2.0.css" /> 
    <script src="/themes/site_theme/js/jquery-1.7.1.min.js"></script> 
    <script src="/themes/site_theme/js/jquery.mobile-1.2.0.js"></script> 
    <script src="/themes/site_theme/js/min.js"></script> 
</head> 
<body><div data-role="page" id="registerPage"> 
<div data-role="header"> 
     <a href="/app/index" data-icon="home" data-theme="b">Home</a> 
     <h1>Brand List</h1> 
     <a href="#" data-role="button" data-rel="back" data-icon="arrow-l"data-theme="b">Back</a> 
</div> 
    <div data-role="content"> 
       <form data-ajax="false" id="textForm" > 
       <textarea name="comments" id="comments" placeholder='Type your comments' size="85"></textarea> 
       <div align="center"> 
        <input data-mini="true" data-inline="true" type="button" value="Submit" onClick="javascript: formText();" /> 
        <input type="hidden" name="company_id" value="3" > 
        <input type="hidden" name="branch_id" value="3" > 
        <input type="hidden" name="campaign_id" value="6" > 
       </div> 
      </form> 

</div> 


<div data-role="dialog" id="dialog1" class="app-dialog"> 
     <div data-role="header"> 
      <h3>A dialog</h3> 
     </div> 
      <div id="content" data-role="content"> 
        <p>I am a dialog....!</p> 
     </div> 
    </div> 



     </div> 
</body> 
</html> 
+0

你有什麼問題嗎? 'formtext()'是怎麼樣的? – Taifun

回答

2

如果我正確理解了你,你想知道如何顯示對話框?如果我是正確的,那麼你有一個錯誤,你的對話是一個registerPage頁面的一部分。只需將其升高一級即可。

看看這個例子中,我把它從你的代碼:http://jsfiddle.net/Gajotres/yWTG2/

$('#registerPage').live('pagebeforeshow',function(e,data){  
    $('#test-button').live('click', function(e) { 
     $.mobile.changePage('#dialog1', { transition: "pop", role: "dialog", reverse: false }); 
    });  
}); 
+1

謝謝!這正是我所期待的。 –

相關問題