dynamic listen for model close

In a sharing mood today. :smiley:

Similar to this blog but slightly updated code.

http://www.mblazonry.com/creating-a-new-opportunity-in-salesforce-using-only-one-model-2/

// Listen for popup close of new record using just one model. // Snippet to be called after creating new row AND displaying popup // Only downside to this is that saving the model in the popup also saves any // other edits in the model. skuid.snippet.registerSnippet('listenForPopupClose',function(args) { var params = arguments[0], $ = skuid.$, row = params.context.row, model = params.context.model; skuid.$(".ui-dialog-content").dialog({ "beforeClose" : function() { var numOfChanges = Object.keys(model.changes).length; // if there is more than row that is currently changed (new, marked for deletion, edited) then this new row will be abandoned. if (numOfChanges &gt; 1){ model.abandonRow(row); // otherwise just mark if for deletion and save } else if (numOfChanges == 1) { model.deleteRow(row); model.save(); } } }); });<br>

How happy are the days when Pat’s in a sharing mood! Thanks for all this good stuff!