I have a table on my page, with a rowaction to show a popup. There are a series of action steps before the popup: Show message, Activate and set a condition, Create a new row, Query model, Run a snippet, Show popup.
The javascript snippet conditionally creates a new row in another model and then saves the row. That row is critical to subsequent activity in the popup dialogue. This is what the javascript looks like (without the conditional coding):
var myModel = skuid.model.getModel('MyModel'); myModel.createRow(); myModel.save();
My understanding is that the save() runs asynchronously, that is, the snippet will complete even if the save is delayed. Potentially, the popup could open and user activity take place without the new row in MyModel. Would a callback function prevent that?
What I have in mind is this change to the save statement:
myModel.save( { callback: function(result) { saveIsDone(result) }} ); function saveIsDone(result) {}
Will a null/empty function such as saveIsDone() be sufficient to force the snippet to wait for the save to complete? Or, do a series of action steps actually continue anyway, so that the popup is already being displayed while the snippet runs?
(And is there any way to test the scenario, that is, to force a delay in saving the myModel row?)