jquery对话框

时间:2009-07-24 18:28:50

标签: javascript jquery escaping dialog

我很难用这个特殊的对话框动作找到答案。问题是当用户按下“enter”(keyCode = 13)按钮时,对话框关闭......就像按下'esc'键一样。即使按下“enter”,我也想保持对话框打开。

相当简单的代码,来自jquery(1.2.6)的简单对话框。

我有一个填充对话框的ajax请求

var div = $("`<div>`testing`</div>`");

$.ajax({

       type      :"GET",
       dataType  : "html",
       cache     : false,
       async     : false,
       url       : WorldWideInventory.baseURL+"/templates/invoice_invoicenumber_confirm.tpl.html",
       error     : function(){ alert("Failed to Connect to Server, Please try Again");},
       success   : function(response){
                  div.html(response);
       }
});

div.appendTo("#APO_Wrapper").dialog({

            width:662,
            height:407,
            closeOnEscape: true,
            bgiframe: true,  
            modal: true,
            title: "Confirm Invoice Number",
            beforeClose: function(){return false;},
            close: function(){return false;} 

});

多数民众赞成......这是疯狂的,任何人对此问题都有任何建议/答案?好的业力将以你的方式发送!!

1 个答案:

答案 0 :(得分:0)

您遇到的问题是因为激活对话框时关闭链接正在被关注,所以当用户点击进入时,它会有效地调用关闭对话框命令。

当使用对话框上的打开事件打开对话框时,尝试将焦点放在另一个可单击元素(例如按钮,链接,表单元素等)上,类似于:

div.appendTo("#APO_Wrapper").dialog({

            width:662,
            height:407,
            closeOnEscape: true,
            bgiframe: true,  
            modal: true,
            title: "Confirm Invoice Number",
            open: function(event, ui){ $("#someOtherSelector").focus(); }

});

了解你的情况。但是当前版本的jQuery和jQuery UI不会发生这种情况,所以如果你可以更新,我建议你这样做。