簡體   English   中英

jQuery UI模式對話框在關閉前會掛起

[英]jQuery UI modal dialog hangs before closing

當我單擊對話框上的“是”按鈕時,它將在屏幕上停留5-10秒鍾,直到startProcess()函數完成。 在startProcess()開始之前,對話框是否應該關閉? 我希望對話框立即關閉而不是等待startProcess()完成來響應。

  $("#dialog-confirm").dialog({ dialogClass: 'no-close', resizable: false, autoOpen: false, maxWidth: 600, width: 400, fluid: true, height: 'auto', modal: true, buttons: { "Yes": function() { $(this).dialog("close"); startProcess(); return true; }, No: function() { $(this).dialog("close"); return false; } } }).css("font-size", "14px"); 

您需要使startProcess()異步運行。 您可以這樣做:

"Yes": function() {
    $(this).dialog("close");
    setInterval(startProcess, 1);
    return true;
},

.dialog("close")只是將對話框隱藏在DOM中。 但是,在函數返回之前,瀏覽器不會基於DOM更新顯示。

暫無
暫無

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

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