【问题标题】:Jquery UI dialog cannot call methods on dialog prior to initialization; attempted to call method 'isOpen'Jquery UI 对话框在初始化之前不能调用对话框上的方法;试图调用方法“isOpen”
【发布时间】:2013-02-21 01:07:03
【问题描述】:

我使用我的代码如下。如果对话框已经打开,则函数 get_devcies_full 将被调用 5 次不要再次打开它,只需更新内容然后我将编码 Bellow 我在 javascript 中遇到错误

无法在初始化之前调用对话框上的方法; 试图调用方法isOpen

function get_devcies_full(id,slno)
{
    $.post("user/get_full_device/" +id + "/" +slno,
        function(data) {
            var NewDialog = $('<div id="MenuDialog"></div>');
            if (NewDialog.dialog( "isOpen" )!==true){
                NewDialog.dialog({
                    modal: true,
                    title: "Title",
                    width :940,
                    height:600,
                }); 
            }
            NewDialog.html(data);
            var t = setTimeout(function () {get_devcies_full(id,slno);},5000);
        }
    );
}

请给出我遇到问题的解决方案?

【问题讨论】:

  • 您的问题标题不是自我解释的,并且您在描述中遇到的问题没有任何解释。
  • 你可能是想写第一行:var NewDialog = $("#MenuDialog");

标签: javascript jquery jquery-ui jquery-ui-dialog


【解决方案1】:

试试这个:

function get_devcies_full(id,slno)
{
    $.post("user/get_full_device/" +id + "/" +slno,
        function(data) {
            if(!($("#MenuDialog").length))//if this div created for first time
            {
                $(body).append('<div id="MenuDialog"></div>');//First time you have to append this in body  
            }
            if (!$('#MenuDialog').dialog('isOpen'))
            //Try if not works => if(!($("#MenuDialog").parents(".ui-dialog").is(":visible")))
            {
                $("#MenuDialog").dialog({
                    modal: true,
                    title: "Title",
                    width :940,
                    height:600    
                });
            }
            $("#MenuDialog").html(data);
            var t = setTimeout(function () {get_devcies_full(id,slno);},5000);
        }
    );
}

【讨论】:

猜你喜欢
  • 2014-06-10
  • 2013-03-08
  • 2019-10-02
  • 1970-01-01
  • 2014-04-13
  • 2023-03-04
  • 2012-11-11
  • 1970-01-01
  • 2013-07-27
相关资源
最近更新 更多