Jquery对话框对话框不是一个函数

时间:2014-08-31 09:00:41

标签: javascript jquery dialog

我正在尝试在我的应用程序中使用jquery对话框,但它不起作用,它说TypeError:$(...)。dialog不是来自mozilla控制台的函数,这是我的代码

<link rel="stylesheet" href="css/jquery-ui.css">
<script src="js/jquery.js"></script>
<script src="js/jquery-ui.js"></script>



<div id="dialog-message" title="Important information">
    <div style="margin-left: 23px;">
        <p>
            We're closed during the winter holiday from 21st of December, 2010 until 10th of January 2011.
        </p></div>
</div>

<script >
    $(function() {

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

    });
</script>

我正在开发一个使用其他javascript库的应用程序,为了避免冲突,我在使用jquery文件之后放了我的对话框脚本,但仍然是同样的问题。可能是什么问题??

2 个答案:

答案 0 :(得分:2)

由于大多数javascript库都使用美元符号$来操作它们的函数,包括不同的javascript发生冲突,所以为了避免这个问题,并且为了解决这个问题,我使用了这个jquery函数,并且它可以正常工作

     var $j = jQuery.noConflict();

然后使用$ j代替$这样:

     $j(function() {

    $j("#dialog-message").dialog({
        modal: true,
        draggable: false,
        resizable: false,
        position: ['center', 'center'],
        width: 500,
        height: 250,
        dialogClass: 'ui-dialog-osx',
        buttons: {
            "I've read and understand this": function() {
                $j(this).dialog("close");
            }
        }
    });

});

它没有任何错误。

答案 1 :(得分:0)

请确认:

  1. 通过webserver(http)运行应用程序来加载jquery-ui.js。在Firefox&#39; Network&#39;下的Firefox本机调试器中或者在&#39; net&#39;

  2. 下的Firebug中
  3. 并验证jquery-ui.js有&#39;对话框&#39;模块

相关问题