I've got an icon with a process attribute so when I click on the icon an ajax submit is triggered.
Now, as long as the icon's action is running I want to block the page with jQuery's blockUI() function. It works perfectly fine with regular submits (without ajax), but on ajax submits the page is only blocked for a short time so it is falsely possible to make a second submit before the first one is finished.
I analyzed the network traffic in Firefox and noticed the following:
On a regular submit (without ajax) the POST-method's answer is "302 Found" while on an ajax submit a redirect is performed so the answer here is "200 OK" with the answer message
<partial-response><redirect url="myURL"></redirect></partial-response>.
I debugged and realized that at some point I end up in PrimeFaces' core.js file with the function PrimeFaces.ajax.ResponseProcessor.doRedirect(a); which again calls window.location.assign(b.getAttribute('url')).
With this assign, the blockUI is lost.
My question: What can I do so the blockUI is not lost on an ajax redirect?
I am using the following code in my xhtml-file:
<p:ajaxStatus onstart="onGlobalAjaxStart()" oncomplete="onGlobalAjaxComplete()" />
The function onGlobalAjaxStart() does the following:
$.blockUI.defaults.overlayCSS = {};
let message = $('#blockUI').attr('pt:message'); // gets the text for the blockUI message
$.blockUI({ message: message});
The function onGlobalAjaxStart() calls $.unblockUI() (among others).