简体   繁体   English

jQuery对话框

[英]jquery dialog box

I am having quite a hard time trying to find some answers with this particular dialog box action. 我很难用这个特定的对话框动作来找到一些答案。 The problem is when the user presses the "enter" (keyCode = 13) button, the dialog closes...as if the 'esc' key was pressed. 问题是,当用户按下“ enter”(输入键代码= 13)按钮时,对话框关闭...就像按下了“ esc”键一样。 I want to keep the dialog box open even when "enter" is pressed. 我想保持对话框打开,即使按下“ enter”也是如此。

Fairly simple code, simple dialog box from jquery (1.2.6). 相当简单的代码,来自jquery(1.2.6)的简单对话框。

I have an ajax request populating the dialog box 我有一个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;} 

});

Thats it...this is driving crazy, anyone have any suggestions/answers to this problem? 就是这样...这真是疯了,有人对这个问题有任何建议/答案吗? Good karma will be sent your way!! 好的业障将按照您的方式发送!

The problem you're experiencing is because the close link is being given focus when the dialog is activated, so when the user hits enter it's effectively calling the close dialog command. 您遇到的问题是,在激活对话框时,关闭链接被赋予焦点,因此当用户点击Enter时,它实际上是在调用关闭对话框命令。

Try giving focus to another clickable element (such as a button, link, form element, etc) when the dialog is opened using the open event on the dialog, similar to: 使用对话框上的打开事件打开对话框时,尝试将焦点放在另一个可单击的元素(例如按钮,链接,表单元素等)上,类似于:

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

});

See how you go with that. 看看你如何去做。 This doesn't happen with the current version of jQuery and jQuery UI though, so if you can update, I'd recommend that. 但是,当前版本的jQuery和jQuery UI不会发生这种情况,因此,如果您可以进行更新,建议您这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM