Is there any way to accomplish something like this?
Basically, after our users are finished with a page I want to evaluate some fields and perform a few actions on the values of those fields. But the fields might change several times, and I only want to run the script once, so I can’t really use a model action… unless I’m missing something?
I can create a ‘close’ button that runs multiple actions… but this doesn’t account for users closing the window. Do I have to just train our users to never close their browser windows, and always use the ‘close’ button?
Thanks!
Page 1 / 1
You can use the window onbeforeunload event.
$(window).on('beforeunload',function(){<br> // If returnMessage is never defined, no warning message will be thrown<br> var returnMessage;<br> $.each(skuid.model.getModel('Contacts').getRows(),function(i,row){<br> if (!row.FirstName) {<br> returnMessage = 'One or more Contacts does not have a FirstName. Are you sure you want to leave the page without giving them a First Name?';<br> return false;<br> }<br> });<br> return returnMessage;<br>});
More more details, see the docs:
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
Sweet! Thanks, Zach!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.