Sta*_*hil 14 jquery jquery-mobile
我正在尝试创建一个对话框Jquery mobile.我试图在这个SO问题中提到已接受的答案,但它对我不起作用.
这是我的代码:
<div data-role="page" id="first">
<!-- Code -->
<div id = "dialog" data-rel="dialog">
<div id = "errorText"></div>
<button id = "closeDialog">OK</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这里是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();
Run Code Online (Sandbox Code Playgroud)
当达到创建对话框的代码时,没有任何反应.建议?
小智 14
该对话框应该是一个单独的页面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>
Run Code Online (Sandbox Code Playgroud)
Hom*_*mer 11
这对我有用,来自http://jquerymobile.com/demos/1.0b1/#/demos/1.0b1/docs/pages/docs-pages.html的"本地,内部链接"页面""部分
http://jsfiddle.net/homer2/ra7Hv/
<div data-role="page" id="foo">
<div data-role="header">
<h1>
Foo
</h1>
</div><!-- /header -->
<div data-role="content">
<p>
I'm first in the source order so I'm shown as the page.
</p>
<p>
View internal page called <a href="#bar" data-rel="dialog">bar</a>
</p>
</div><!-- /content -->
<div data-role="footer">
<h4>
Page Footer
</h4>
</div><!-- /footer -->
</div><!-- /page -->
<!-- Start of second page -->
<div data-role="page" id="bar">
<div data-role="header">
<h1>
Bar
</h1>
</div><!-- /header -->
<div data-role="content">
<p>
I'm second in the source order so I'm not shown as the page initally.
</p>
<p>
<a href="#foo">Back to foo</a>
</p>
</div><!-- /content -->
<div data-role="footer">
<h4>
Page Footer
</h4>
</div><!-- /footer -->
</div><!-- /page -->
Run Code Online (Sandbox Code Playgroud)