[英]Wait for Ajax to render (JSF)
I have a PRIMEFACES dialog, in wich I use onCloseUpdate atribute to re-render all the content of the dialog when dialog is closed. 我有一个PRIMEFACES对话框,在关闭对话框时,我使用onCloseUpdate属性重新渲染对话框的所有内容。 The problem is that when I close the dialog, and (fast) click to open it again, I see that onCloseUpdate hasn't finished re-rendering the content of the dialog, and old content is displayed for a half second/second period.
问题是,当我关闭对话框并(快速)单击以再次将其打开时,我看到onCloseUpdate尚未完成重新呈现对话框的内容,并且旧内容显示了半秒/秒。
Here's the command link that make dialog visible: 这是使对话框可见的命令链接:
<h:commandLink id="area1" onclick="dlg.show()">
...
</h:commandLink>
, and here's the dialog: ,这是对话框:
<ppctu:dialog onCloseUpdate="... here is all the component ids from the dialog content ..." modal="true" widgetVar="dlg">
Is there some way to wait for onCloseUpdate rendering to complete? 有什么方法可以等待onCloseUpdate渲染完成吗?
Thanks in advance 提前致谢
Use synchronous ajax call.Synchronous AJAX (Really SJAX -- Synchronous Javascript and XML) is modal which means that javascript will stop processing your program until a result has been obtained from the server. 使用同步Ajax调用。同步AJAX(实际上是SJAX-同步Javascript和XML)是模态的,这意味着javascript将停止处理您的程序,直到从服务器获得结果为止。 While the request is processing, the browser is effectively frozen.
在处理请求期间,浏览器实际上被冻结。
function getFile(url) {
if (window.XMLHttpRequest) {
AJAX=new XMLHttpRequest();
} else {
AJAX=new ActiveXObject("Microsoft.XMLHTTP");
}
if (AJAX) {
AJAX.open("GET", url, false); //notice the 'false' attribute
AJAX.send(null);
return AJAX.responseText;
} else {
return false;
}
}
If you are using jQuery then put async:false
in your ajax call var fileFromServer = getFile('http://somedomain.com/somefile.txt'); 如果您使用的是jQuery,则在ajax调用中放入
async:false
false。var fileFromServer = getFile('http://somedomain.com/somefile.txt');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.