2011-08-21 48 views
1

我想为在jQuery UI的dialog.I JavaScript的核心确认()的替代品使用此代码 bellow.But返回一些错误的替代品。使用jQueryUI的对话框,对JavaScript核心确认()

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.So的多个实例反正我的代码工作 完美now.Even虽然我”后已经看到,在{digOpn();返回false} “返回false”不等待我的UI对话框中单击值,并执行 immediately.But不找我麻烦though.Thanks为 你的那种赞赏。

+0

什么jQuery和jQuery UI的版本是您使用? –

+0

jQuery UI 1.8.16和jQuery v1.6.2 –

+0

我只是想在digOpn()中显示一个确认对话框,所以你可以改变我的代码到工作区。 –

回答

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/

+0

我已经更新了我的代码。 'else { digOpn(); 返回false; }现在我可以确认返回false。 –

+0

@ neo-nant:你的代码中没有显示'fb_ses()'的作用。你的错误肯定存在... –