如何使用单击事件使用移动jQuery在移动设备中弹出对话框



我尝试了一些片段,但是某些对我不起作用的方法可能是我的方法是不正确的。

它只是显示对话框wihout poping

这是我完成的代码。有些身体请帮助我。

我在jsbin.com编辑中尝试了此代码。

<!DOCTYPE html>
<html>
<head>
 <link href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css"     rel="stylesheet" type="text/css" />
 <script type="text/javascript" charset="utf-8"   src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>  
 </head>
 <body>
 <div id="divid" data-rel="dialog" > 
 dialog
 </div>

</div>

<script>
(function(){
  $.mobile.changePage( $('#divid'), { role: 'dialog', transition: 'pop'} );

})();
</script>

</body>
</html>

注意:对话框小部件在 1.4 中弃用,并将在 1.5 中删除。页面小部件现在具有对话框选项

在JQuery Mobile时,没有data-role=dialog,可以通过添加data-dialog="true"属性将页面转换为对话框,

<div data-role="page" data-dialog="true" id="foo">
  <div data-role="header" data-close-btn="right">
     <h1>Dialog</h1>
  </div>
  <!-- contents -->
</div>

以编程方式称其为:

$.mobile.pageContainer.pagecontainer("change", "#foo", {
    transition: "pop"
});

演示

最新更新