创建对话框JQuery Mobile [英] Creating a dialog JQuery Mobile

查看:76
本文介绍了创建对话框JQuery Mobile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Jquery mobile创建一个对话框.我已尝试在此问题中引用已接受的答案 ,但这对我没有用.

I am trying to create a dialog with Jquery mobile. I have tried to refer to the accepted answer in this SO question but it didn't work for me.

这是我的代码:

 <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(在函数内部):

And here is the JS to make it (inside a function):

//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();

到达创建对话框的代码时,什么也没有发生.有建议吗?

When the code to create the dialog is reached nothing happens. Suggestions?

推荐答案

对话框应该是一个单独的页面div,您可以通过Ajax加载该页面或将其包含在HTML中.这是一个例子.

The dialog should be a separate page div which you can load via Ajax or include in your HTML. Here is an example.

<!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 Mobile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆