开发者

Using jqueryui dialog as a substitute for javascript core confirm()

I want to make a substitute for javascript core confirm() in jquery ui dialog.I use this code bellow.But it returns some error.

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-c开发者_如何学Conf").dialog("open");
    CreateDialog();
}
function sess_chk(){
   if(fb_ses())return true; 
   else 
   {
       digOpn();
       return false;
    } 
}

Now when i call sess_chk() function from my code in an onclick event it doesn't fire ui dialog rather throw an error

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

What am i doing wrong here.??!!

EDIT:

After some debugging i have seen that 'propAttr' error was popping because of multiple instance of jquery ui.So anyway my code is working perfect now.Even though i've seen that in {digOpn();return false} "return false" doesn't wait for my ui dialog click value and executes immediately.But that doesn't cause me any trouble though.Thanks for your kind appreciations.


Your error must be elsewhere on your page (you don't even have propAttr in the code you posted).

The following piece of code works perfectly for me:

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();

Here's the fiddle: http://jsfiddle.net/TBbAm/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜