【问题标题】:Jquery Dialog - Object doesn't support this property or MethodJquery Dialog - 对象不支持此属性或方法
【发布时间】:2011-03-03 13:40:44
【问题描述】:

在我升级到 Jquery 较新版本之前,我的这段代码运行良好。现在我得到了上述错误。

 <link rel="stylesheet" type="text/css" href="site.css" />
    <link type="text/css" href="css/smoothness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />   
     <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8.10.custom.min.js"></script>    
    <script type="text/javascript" src="js/ddsmoothmenu.js"></script>

    <script type="text/javascript">    
         $(document).ready(function(){     
                $('#dialog').dialog({
                    modal: true,
                    autoOpen: false,
                    width: 760,
                    height: 'auto',             
                    close: function(event, data) {
                        $('#mainFrame')[0].src = "LoadingPage.aspx";
                    }
                });
                $('a[name="dia"]').click(function(){
                    $('#mainFrame')[0].src = this.file;
                    $('#dialog').data('title.dialog', this.innerText); 
//                    $('#dialog').data('width.dialog', this.diaWidth); 
//                    $('#dialog').data('height.dialog', this.diaHeight); 
                    $('#dialog').dialog('open');
                    return false;
                });             

                if (document.getElementById('hidIsAdmin').value == "1"){
                    document.getElementById('liAdmin').style.display = 'block';
                    document.getElementById('liReports').style.display = 'block';
                }else {
                    $('#liAdmin').remove();
                    $('#liReports').remove();

                }
                if (document.getElementById('hidCreate').value == "1"){
                    document.getElementById('liCreate').style.display = 'block';
                }else {
                    $('#liCreate').remove();
                    $('.edit_icon_link').hide(0);                   
                }
            });
            function hideEditIcon(){
                $('.edit_icon_link').hide(0);                   
            }            
    </script>

【问题讨论】:

  • 您使用的 jQuery UI 版本是否与 jQuery 版本兼容?您可能需要下载更新的版本。
  • 你到底升级了什么?什么文件?
  • 我将 jquery-1.3.2.min.js 更改为 jquery-1.4.4.min.js 并将 jquery-ui-1.7.1.custom.min.js 更改为 jquery-ui-1.8。 10.custom.min.js 和 css jquery-ui-1.7.1.custom.css 到 jquery-ui-1.8.10.custom.css。就这样。它在以前的版本中运行良好。
  • 确保文件确实是使用 HttpWatch 加载的。
  • 这是以前使用旧文件名和现在使用新文件名的方式。

标签: jquery jquery-ui dialog


【解决方案1】:

我发生了类似的事情(将 MVC3 ASP 转换为 Razor),就我而言,将我的 jquery-1.4.4.min.js 引用移动到我的母版页有所帮助。

我说 “帮助”,因为现在 open 有效,但 $(this).dialog("close"); 无效。

function ShowPopUp(strDivName)
{
    $("div[id$='" + strDivName + "']").dialog(
        {
            title: "blah blah blah",
            width: 600,
            modal: true,
            resizable: true,
            closeOnEscape: false,
            buttons:
            {
                "Save": function () { SaveThis(); $(this).dialog("close"); },
                "Cancel": function () { $(this).dialog("close"); }
            }
        }
    );
    $("div[id$='" + strDivName + "']").dialog("open");
}

【讨论】:

    【解决方案2】:

    检查对话框可用的选项,我认为 autoResize 已重命名为 resizable。

    【讨论】:

    • 但它不会产生“对象不支持..”错误..或者可以吗? ://
    • { resizable : true } 允许用户拖动对话框的边缘来调整它的大小。 AutoResize 似乎是别的东西,虽然我没有在文档中看到它。
    【解决方案3】:

    您是否有可能没有关闭您的 $(document).ready(function(){

    您在上面显示的}); 关闭了$('#dialog').dialog({,但我没有看到$(document).ready(function(){ 的关闭。

    【讨论】:

    • $(document).ready(function(){ $('#dialog').dialog({ modal: true, autoOpen: false, width: 760, height: 'auto', close:函数(事件,数据){ $('#mainFrame')[0].src = "LoadingPage.aspx"; } });$('a[name="dia"]').click(function(){ $('#mainFrame')[0].src = this.file; $('#dialog').data('title.dialog', this.innerText); $('#dialog').dialog('open '); 返回 false; });
    • if (document.getElementById('hidIsAdmin').value == "1"){ document.getElementById('liAdmin').style.display = 'block'; document.getElementById('liReports').style.display = 'block'; }else { $('#liAdmin').remove(); $('#liReports').remove(); } if (document.getElementById('hidCreate').value == "1"){ document.getElementById('liCreate').style.display = 'block'; }else { $('#liCreate').remove(); $('.edit_icon_link').hide(0); }
    • });函数 hideEditIcon(){ $('.edit_icon_link').hide(0); }
    • @user643062 请编辑您的问题并在此处添加代码,将整个代码放入 cmets 是不可读的。
    • 影子向导 - 完成,如果您需要任何其他信息,请告诉我。一切工作正常,如果只是用旧版本替换以下 3 行,相同的代码仍然可以正常工作。
    【解决方案4】:

    我在使用 IE8 时遇到了这个问题,因为我在一个 HTTPS 页面上但从 HTTP CDN 加载 jquery-ui 包。一旦我将网址更改为

    http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js

    https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js

    它开始工作了。

    【讨论】:

      【解决方案5】:

      我现在正在使用 MVC4。所以我必须将 jquery-ui-1.8.20.js 添加到 App_Start 下的 BundleConfig.RegisterBundles() 以使其工作:

      bundles.Add( new ScriptBundle( "~/bundles/jquery" ).Include(
        "~/Scripts/jquery-{version}.js",
        "~/Scripts/jquery-ui-1.8.20.js" ) );
      

      【讨论】:

        猜你喜欢
        • 2013-03-23
        • 2011-02-02
        • 1970-01-01
        • 2011-08-25
        • 1970-01-01
        • 2013-10-05
        • 1970-01-01
        • 2011-02-14
        相关资源
        最近更新 更多