jQuery dialog()可以在一个页面上工作,但不能在另一个页面上工作

jQuery dialog() works on one page but not on another

本文关键字:工作 但不能 另一个 dialog jQuery 一个      更新时间:2023-09-26

我有一个包含jQuery和jQuery UI的页面,从div元素创建一个模态对话框。这很好。现在,在具有相同HTML标记和对相同JavaScript文件的引用的另一个页面上,我做了完全相同的事情,并得到以下错误:

Internet Explorer 8:

对象不支持此属性或方法

铬(26.0.1410.64):

未捕获的TypeError: object#没有方法'dialog'

这是两个页面中HTML的样子:

<div id="dialog-message" class="ui-widget" style="margin-left: auto; margin-right: auto; display: none;" title="Activity Monitoring">
    <p>
        <span id="messageContainer"></span>
    </p>
</div>

这是第二页出错的代码。注意,第一行被正确执行,并且'messageContainer'的内容被正确设置:

$('#messageContainer').html(message);
$('#dialog-message').dialog({
    autoOpen: false,
    bgiframe: true,
    draggable: false,
    height: "auto",
    modal: true,
    open: function (event, ui) { $(".ui-dialog-titlebar-close").hide(); },
    position: { my: "center", at: "center", of: window },
    resizable: false,
    width: 450,
    buttons: dialogButtons
});

这些是jquery文件的包含。出于隐私原因,我省略了部分路径,但我验证了它,并且在成功执行第一行jQuery代码时它可以工作。第三个包含是对编写上述JavaScript代码的文件的引用:

<script language="javascript" type="text/javascript" src="http://.../javascript/jquery-1.8.2.min.js"></script>
<script language="javascript" type="text/javascript" src="http://.../javascript/jquery-ui-1.10.2.custom.min.js"></script>
<script language="javascript" type="text/javascript" src="http://.../javascript/Utility.js"></script>

我是不是漏掉了什么?我无法找出为什么在一页这工作完美,在另一个我得到错误。提前感谢!

检查是否两次包含jquery UI

相关文章: