I've found out that the afterPostback
event is not being called when Context.ReturnFile()
is used in the ViewModel
. I use the following code to disable all the buttons on the page when postback is sent and enable them again after the postback
is finished:
dotvvm.events.beforePostback.subscribe(function () {
$('.btn-primary').prop('disabled', true).addClass('m-progress');
});
dotvvm.events.afterPostback.subscribe(function () {
$('.btn-primary').removeAttr('disabled').removeClass('m-progress');
});
However, when some ViewModel
uses Context.ReturnFile()
to return a generated file, the afterPostback
is not called and all the buttons on the page stay disabled.
I've also tried to use spaNavigating
and spaNavigated
events, but they don't seem to be called either.
Is there some workaround or another event that is called when a file is returned from ViewModel
?
The Context.ReturnFile
uses redirect internally and redirect doesn't fire this event.
I have filed a GitHub issue and we will see if we can change the behavior for the afterPostback
event to be called on redirects. If not, we will introduce a new event just for this case.