开发者

Wait for Ajax to render (JSF)

开发者 https://www.devze.com 2023-03-29 11:18 出处:网络
I have a PRIMEFACES dialog, in wich I use onCloseUpdate atribute to re-render all the content of the dialog when dialog is closed. The problem is that when I close the dialog, and (fast) click to open

I have a PRIMEFACES dialog, in wich I use onCloseUpdate atribute to re-render all the content of the dialog when dialog is closed. 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.

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="... h开发者_运维知识库ere is all the component ids from the dialog content           ..."  modal="true" widgetVar="dlg">

Is there some way to wait for onCloseUpdate rendering to complete?

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. 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');

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号