0

是否有任何方法在使用jQuery Mobile進行頁面加載之前調用/顯示對話框或彈出窗口?如何在頁面加載之前使用jquery mobile加載對話框或彈出窗口

我想要得到的網頁加載之前的一些輸入,並根據該輸入下一個頁面將被載入

+0

我想要得到的網頁加載之前的一些輸入,並根據該輸入下一個頁面將被載入 – Prasad 2013-05-08 12:44:57

+0

的解決方案是,http://stackoverflow.com/a/10285950/1722141 – Prasad 2013-05-08 12:49:47

+0

茹建議這是重複的? – Freelancer 2013-05-08 12:51:04

回答

2

加載對話框或在顯示頁面之前的彈出窗口,您需要使用seTimeout。如果你毫不遲疑地打電話,它會馬上打開和關閉。

$(document).on('pagebeforeshow', '#pageID', function() { 
setTimeout(function() { 
    $('#popupID').popup('open'); 
}, 100); // delay above zero 
}); 

Similar issue.

1

有一個非常簡單的解決你的問題,只是你需要做的事情就是讓你的第一個頁面是一個對話框。

工作例如:http://jsfiddle.net/Gajotres/dj3UP/1/

正如你可以看到它在我的例子,這是一個純HTML的解決方案。第一頁數據角色屬性更改爲對話框

HTML:

<!DOCTYPE html> 
<html> 
<head> 
    <title>jQM Complex Demo</title> 
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> 
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>  
</head> 
<body> 
    <div data-role="dialog" id="index"> 
     <div data-theme="a" data-role="header"> 
      <h3> 
       First Page 
      </h3> 
     </div> 

     <div data-role="content"> 
      <input type="text" value="" id="some-input"/> 
      <a data-role="button" id="some-button" href="#second">Next page</a> 
     </div> 

     <div data-theme="a" data-role="footer" data-position="fixed"> 

     </div> 
    </div> 
    <div data-role="page" id="second"> 
     <div data-theme="a" data-role="header"> 
      <h3> 
       Second Page 
      </h3> 
      <a href="#index" class="ui-btn-left">Back</a> 
     </div> 

     <div data-role="content"> 

     </div> 

     <div data-theme="a" data-role="footer" data-position="fixed"> 

     </div> 
    </div>  
</body> 
</html> 
相關問題