I have a SignalR process feeding updates to a viewModel using Kendo's observable. Everything is working was expected, but I needed to add a confirm popup for the user, and now it's not working as I expect it to. The singlaR process gets a specific value, in which case I update the javascript viewModel and ask the user a question via the javascript confirm function. What's happening is the updated viewmodel values aren't displaying on the screen until after the user answers the confirm. I expected the values on the screen to update before the confirm pops up, but that's not happening. How can I make it do so?
status.on(
"sendGTNProgress"
,
function
(theStats) {
var
statObj = JSON.parse(theStats);
if
(statObj.ProcessMessage ===
"FILE READY"
) {
viewModel.set(
"processMessage"
,
"GTN Report Generated and Ready for Download"
);
viewModel.set(
"processName"
,
"File Name: "
+ statObj.ProcessName);
viewModel.set(
"currentRecMsg"
,
"Your report file is in the appropriate network directory"
);
viewModel.set(
"progressMsg"
,
"@ConfigurationManager.AppSettings["
ReportDir
"]"
);
AskToDownload();
}
});
function
AskToDownload() {
if
(confirm(
"Do you want to download this file locally?"
)) {
window.open(
"@Url.Action("
GetGTNFile
", @"
GTNReport
")?theFile="
+ viewModel.get(
"processName"
).replace(
"File Name: "
,
""
),
"_blank"
);
}
}