简体   繁体   English

使jQuery ui对话框不起作用?

[英]Making a jQuery ui dialog not working?

I have some code here that's supposed to produce a dialog box using the jquery ui. 我这里有一些代码,应该使用jquery ui产生一个对话框。

CSS CSS

        body { font: normal normal normal 10px/1.5 Arial, Helvetica, sans-serif; }

    .ui-dialog-osx {
        -moz-border-radius: 0 0 8px 8px;
        -webkit-border-radius: 0 0 8px 8px;
        border-radius: 0 0 8px 8px; border-width: 0 8px 8px 8px;
    }

LIBRARIES 图书馆

<script type="text/javascript" src="scripts/jquery-1.11.0.js"></script>
<script type="text/javascript" src="scripts/jquery.cookie.js"></script>
<script type="text/javascript" src="scripts/jquery-1.10.2.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.10.4.custom.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.10.4.custom.min.js"></script>

JS JS

$("#dialog-message").dialog({
    modal: true,
    draggable: true,
    resizable: true,
    position: ['center', 'top'],
    show: 'blind',
    hide: 'blind',
    width: 400,
    dialogClass: 'ui-dialog-osx',
    buttons: {
        "I've read and understand this": function() {
            $(this).dialog("close");
        }
    }
});

HTML HTML

Hello World! 你好,世界!

<div id="dialog-message" title="Important information">
    <span class="ui-state-default"><span class="ui-icon ui-icon-info" style="float:left; margin:0 7px 0 0;"></span></span>
    <div style="margin-left: 23px;">
        <p>
            We're closed during the winter holiday from 21st of December, 2010 until 10th of January 2011.
            <br /><br />
            Our hotel will reopen at 11th of January 2011.<br /><br />
            Another line which demonstrates the auto height adjustment of the dialog component.
        </p></div>
</div>

I actually found it on this fiddle using Google. 我实际上是使用Google在这个小提琴上找到的。 I noticed that the fiddle is using jQuery 1.5.2 but I don't have that library (I download them so I can code offline). 我注意到小提琴使用的是jQuery 1.5.2,但我没有该库(我下载了它们,以便可以离线编写代码)。 This code doesn't work for me on my local browser even though it works for fiddle. 即使对小提琴有效,此代码也不适用于我的本地浏览器。 When I change the library the fiddle uses to jQuery 1.11.0 (which is the one I have in my laptop locally), the fiddle fails. 当我将小提琴更改为jQuery 1.11.0(这是我在本地笔记本电脑中使用的小提琴)使用的库时,小提琴失败。

I was thinking if I have the latest jQuery version, that would be enough to support the new features? 我在想如果我有最新的jQuery版本,那足以支持新功能吗? Or do I need to download this library separately? 还是我需要单独下载该库?

When I look at the console for errors, there are no errors. 当我查看控制台中的错误时,没有任何错误。 So there's that out of the way. 这样就可以了。

What's the problem here? 这是什么问题

Try to include jQuery and jQueryUI once instead of twice like what you're doing at this moment: 尝试一次包含jQueryjQueryUI ,而不是像现在这样包含两次:

<script type="text/javascript" src="scripts/jquery-1.10.2.js"></script>
<script type="text/javascript" src="scripts/jquery.cookie.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.10.4.custom.min.js"></script>

and also wrap your code inside DOM ready handler: 并将您的代码包装在DOM ready处理程序中:

$(function() {
     // Your jQuery code here
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM