使用jqueryui对话框替代javascript核心确认()

时间:2011-08-21 07:14:17

标签: jquery jquery-ui-dialog confirm

我想在jquery ui dialog中替换javascript core confirm()。我使用这段代码 但是它会返回一些错误。

function CreateDialog(){
$("#diag-conf").dialog({show:'drop',hide:'drop',autoOpen:false,resizable:false,draggable:true,height:150,width:410,title:'Facebook Session Error!',modal:true,buttons:{"CONTINUE":function(){$(this).dialog("close");top.location.href=re_auth;},"CANCEL":function(){$(this).dialog("close");}}});
}
function digOpn(){
    var m='my msg';
    $('#digmsg').html(m);
    //$("#diag-conf").dialog("open");
    CreateDialog();
}
function sess_chk(){
   if(fb_ses())return true; 
   else 
   {
       digOpn();
       return false;
    } 
}

现在当我在onclick事件中调用我的代码中的sess_chk()函数时,它不会触发ui对话框而是抛出错误

Uncaught TypeError: Object [object Object] has no method 'propAttr' (jquery-ui.min.js:258)

我在这里做错了什么。?? !!

修改

  

经过一些调试后,我看到'propAttr'错误正在弹出   因为jquery ui的多个实例。所以无论如何我的代码都在工作   现在完美。即使我在{digOpn()中看到过,但返回false}   “return false”不等待我的ui对话框点击值并执行   但是,这并没有给我带来任何麻烦。谢谢   你的赞赏。

1 个答案:

答案 0 :(得分:2)

您的错误必须位于您网页的其他位置(您在发布的代码中甚至没有propAttr。)

以下代码对我来说非常适合:

function CreateDialog() {
    $("#diag-conf").dialog({
        show:'drop',
        hide:'drop',
        autoOpen:false,
        resizable:false,
        draggable:true,
        height:150,
        width:410,
        title:'Facebook Session Error!',
        modal:true,
        buttons:{
            "CONTINUE":function(){
                $(this).dialog("close");
                top.location.href=re_auth;
            },
            "CANCEL":function(){
                $(this).dialog("close");
            }
        }
    });
}
function digOpn(){
    var m ='my msg';
    $('#digmsg').html(m);
    CreateDialog();
    $("#diag-conf").dialog("open");
}

digOpn();

这是小提琴:http://jsfiddle.net/TBbAm/

相关问题