In Prototype, are there AJAX start/stop events that would allow you to create one script for globally displaying a modal wait message during AJAX loads?
Like, with jQuery I'm using this one script in the application layout to globally display a modal wait dialog for any jQuery AJAX events:
<script type="text/javascript">
$(document).ajaxStart(function () {
$.blockUI({ message: '<h1><img src="../images/busy.gif" /> Just a moment...</h1>' });
});
$(document).ajaxStop(function () {
$.unblockUI();
});
</script>
Thanks - much appreciated?
With Prototype you have access to a variable Ajax.activeRequestCount
(more info here)
This contains, at any time, the amount of currently active AJAX requests (those created by Prototype, anyway), by monitoring their onCreate and onComplete events
EDIT
Untested but something like this should work:
Ajax.Responders.register({
onCreate: showProcessing,
onComplete: hideProcessing
});
function showProcessing() {
if(Ajax.activeRequestCount > 0){
$('inProgress').show();
}
}
function hideProcessing () {
if(Ajax.activeRequestCount <= 0){
$('inProgress').hide();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With