[英]jQuery UI modal dialog hangs before closing
When I click the "Yes" button on the dialog box, it will stay on screen for 5-10 seconds until the startProcess() function completes. 当我单击对话框上的“是”按钮时,它将在屏幕上停留5-10秒钟,直到startProcess()函数完成。 Shouldn't the dialog close before startProcess() begins?
在startProcess()开始之前,对话框是否应该关闭? I'd like the dialog to respond right away by closing instead of waiting for the startProcess() to complete.
我希望对话框立即关闭而不是等待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");
You need to make startProcess()
run asynchronously. 您需要使
startProcess()
异步运行。 You could do: 您可以这样做:
"Yes": function() {
$(this).dialog("close");
setInterval(startProcess, 1);
return true;
},
.dialog("close")
simply hides the dialog in the DOM. .dialog("close")
只是将对话框隐藏在DOM中。 But the browser doesn't update the display based on the DOM until the function returns. 但是,在函数返回之前,浏览器不会基于DOM更新显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.