I’m trying to save changes to a model when the user closes the page. I don’t want to give the user a message, I just want to save the models. Here is the code that I’m using, but it seems like it’s working only some of the time. Can someone tell me what I’m doing wrong. Thanks!
(function(skuid){
var $ = skuid.$;
$(document.body).one(‘pageload’,function(){
$(window).on(‘beforeunload’, function () {
saveAllModels();
});
});
})(skuid);
function saveAllModels(){
var SalesOrderModel = skuid.model.getModel(‘SalesOrder’);
var savePromise = SalesOrderModel.save();
}
Question
Saving Models without asking users with beforeunload
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.