簡體   English   中英

jQuery對話框

[英]jquery dialog box

我很難用這個特定的對話框動作來找到一些答案。 問題是,當用戶按下“ enter”(輸入鍵代碼= 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;} 

});

就是這樣...這真是瘋了,有人對這個問題有任何建議/答案嗎? 好的業障將按照您的方式發送!

您遇到的問題是,在激活對話框時,關閉鏈接被賦予焦點,因此當用戶點擊Enter時,它實際上是在調用關閉對話框命令。

使用對話框上的打開事件打開對話框時,嘗試將焦點放在另一個可單擊的元素(例如按鈕,鏈接,表單元素等)上,類似於:

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不會發生這種情況,因此,如果您可以進行更新,建議您這樣做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM