微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

创建一个对话框JQuery Mobile

我试图用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>

原文地址:https://www.jb51.cc/jquery/180406.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐