我正在尝试使用 Jquery mobile
创建一个对话框。我试图引用已接受的答案 in this SO question但这对我不起作用。
这是我的代码:
<div data-role="page" id="first">
<!-- Code -->
<div id = "dialog" data-rel="dialog">
<div id = "errorText"></div>
<button id = "closeDialog">OK</button>
</div>
</div>
这是制作它的 JS(在函数内):
//Nothing checked. Cannot continue. Add error message to div
$('#errorText').html("You must check the checkbox next to \"I Agree\" to continue");
//Open Dialog
$('#dialog').dialog();
当到达创建对话框的代码时,什么也没有发生。有建议吗?
最佳答案
该对话框应该是一个单独的页面 div,您可以通过 Ajax 加载它或将其包含在 HTML 中。这是一个例子。
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Sample</h1>
</div>
<div data-role="content">
<p></p>
<p><a href="dialog.html" data-rel="dialog" data-role="button">Is this a question?</a></p>
</div>
</div>
<div data-role="page" data-url="dialog.html">
<div data-role="header">
<h1>Dialog</h1>
</div>
<div data-role="content">
<p>Is this an answer?</p>
</div>
</div>
</body>
</html>
关于jquery - 创建对话框 JQuery Mobile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6101370/