我已尝试过一些片段,但有些片段对我不起作用可能是我的做法不正确。
它只显示弹出
的对话框这是我完成的代码。 有些人请帮助我。
我在jsbin.com editer中尝试了这段代码。
<!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>
答案 0 :(得分:3)
注意:对话框窗口小部件已弃用 1.4 ,将在 1.5 中删除。页面小部件现在具有对话框选项,当设置为true时,将对话框样式应用于页面。
从jQuery Mobile开始,没有data-role=dialog
,而是可以通过将data-dialog="true"
属性添加到 page div来将页面转换为对话框。
<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"
});
<强> Demo 强>