javascript 类型错误:'undefined' 不是函数(评估 '$( "#wnd_Addparam" ).dialog')

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12909916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 17:25:06  来源:igfitidea点击:

TypeError: 'undefined' is not a function (evaluating '$( "#wnd_Addparam" ).dialog')

javascriptjqueryjquery-uidialog

提问by

I had this example from 2 months and I changed the PC. Now this doesn't seem to work anymore. This is an example that should load a small window's dialog by (before) pushing a button. However, it does not work... This is my code:

我从 2 个月起就有了这个例子,我更换了 PC。现在这似乎不再起作用了。这是一个应该通过(之前)按下按钮来加载小窗口对话框的示例。但是,它不起作用......这是我的代码:

<html>
<head>
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  <script type="text/javascript">
// <---- VENTA?AS DE PARAMETERES---->

var regex,v,l,c,b;
$( "#wnd_Addparam" ).dialog({
            autoOpen: false,
            height: 'auto',
            width: 350,
            modal: true,
            resizable:false,
            buttons: {
                "Add": function() {
                                $( this ).dialog( "close" ); 
                                   },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            },
            close: function() {
                $( this ).dialog( "close" );
            }
        });

        $( "#btn_Addpar" ).click(function() {
                $( "#wnd_Addparam" ).dialog( "open" );
            });
$( "#wnd_Paramedit" ).dialog({
            autoOpen: false,
            height: 'auto',
            width: 350,
            modal: true,
            resizable:false,
            buttons: {
                "Accept": function() {
                      $( this ).dialog( "close" );  

                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            },
            close: function() {
                $( this ).dialog( "close" );
            }
        });

        $( "#btn_Pedit" ).click(function() {
                $( "#wnd_Paramedit" ).dialog( "open" );
            });
$( "#wnd_Borpara" ).dialog({
            autoOpen: false,
            height: 'auto',
            width: 300,
            resizable:false,
            modal: true,
            buttons: {
                "Accept": function() {
                    $(this).dialog("close");

                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            },
            close: function() {
                $( this ).dialog( "close" );
            }
        });

        $( "#btn_Deletepara" ).click(function() {
                $( "#wnd_Borpara" ).dialog( "open" );
            });

</script></head>
<!--<form method="POST" id="iformp" name="nformp">-->
<body>
<h3>List of parameters</h3>
<div id="sortparam" >
</div>
 <input type="button" id="btn_Addpar" value="Add"/>
<input type="button" id="btn_Deletepara" value="Delete"/>
<input type="button" id="btn_Pedit" value="Edit"/>
<!--<form>-->

</body>

</html>

Please.. Why I do have an error for the dialog???

请.. 为什么我的对话框有错误???

采纳答案by Mirko Cianfarani

Now use this code simple....


<html>
    <head>
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
    <script type="text/javascript">
    // <---- VENTA?AS DE PARAMETERES---->
    $(document).ready(function() { 
    var regex,v,l,c,b;
    $( "#wnd_Addparam" ).dialog({
                autoOpen: false,
                height: 'auto',
                width: 350,
                modal: true,
                resizable:false,
                buttons: {
                    "Add": function() {
                                   $( this ).dialog( "close" ); 
                                       },
                    Cancel: function() {
                        $( this ).dialog( "close" );
                    }
                },
                close: function() {
                    $( this ).dialog( "close" );
                }
            });

            $( "#btn_Addpar" ).click(function() {
                    $( "#wnd_Addparam" ).dialog( "open" );
                });

    });
    </script>
    </head>
    <!--<form method="POST" id="iformp" name="nformp">-->
    <body>
    <h3>List of parameters</h3>
    <div id="sortparam" >
    </div>
     <input type="button" id="btn_Addpar" value="Add"/>

    <!--<form>-->

    </body>

    </html>

回答by Fenton

You are referencing the jQuery core, but not jQuery UI itself.

您引用的是 jQuery 核心,而不是 jQuery UI 本身。

I believe the dialogfunction only exists in jQuery UI, so you would need to add the following to your page too:

我相信该dialog功能仅存在于 jQuery UI 中,因此您还需要将以下内容添加到您的页面中:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>

<script type="text/javascript">
// <---- VENTA?AS DE PARAMETERES---->
$(document).ready( function () {
    var regex,v,l,c,b;
    $( "#wnd_Addparam" ).dialog({
        // Your code...
}

回答by clement

I had the same problem. I included jQuery twice on the same webpage (jQuery then jQuery UI then jQuery, and it causes me troubles (exactly the same problem on the .dialog )

我有同样的问题。我在同一个网页上包含了两次 jQuery(jQuery 然后是 jQuery UI,然后是 jQuery,这给我带来了麻烦(在 .dialog 上完全相同的问题)