add saveSuccess hook for detail view
authorScott Baker <smbaker@gmail.com>
Tue, 20 Jan 2015 08:05:02 +0000 (00:05 -0800)
committerScott Baker <smbaker@gmail.com>
Tue, 20 Jan 2015 08:05:02 +0000 (00:05 -0800)
planetstack/core/xoslib/static/js/xoslib/xosHelper.js

index a46fa40..6b6419c 100644 (file)
@@ -475,7 +475,7 @@ XOSDetailView = Marionette.ItemView.extend({
             */
 
             initialize: function() {
-                this.on("saveSuccess", this.onAfterSave);
+                this.on("saveSuccess", this.onSaveSuccess);
                 this.synchronous = false;
             },
 
@@ -485,11 +485,20 @@ XOSDetailView = Marionette.ItemView.extend({
                 });
             },
 
+            saveSuccess: function(e) {
+                // always called after a save succeeds
+            },
+
             afterSave: function(e) {
+                // if this.synchronous, then called after the save succeeds
+                // if !this.synchronous, then called after save is initiated
             },
 
-            onAfterSave: function(e) {
-                this.afterSave(e);
+            onSaveSuccess: function(e) {
+                this.saveSuccess(e);
+                if (this.synchronous) {
+                    this.afterSave(e);
+                }
             },
 
             inputChanged: function(e) {
@@ -559,9 +568,7 @@ XOSDetailView = Marionette.ItemView.extend({
 
                 this.model.save(data, {error: function(model, result, xhr) { that.app.saveError(model,result,xhr,infoMsgId);},
                                        success: function(model, result, xhr) { that.app.saveSuccess(model,result,xhr,infoMsgId);
-                                                                               if (that.synchronous) {
-                                                                                   that.trigger("saveSuccess");
-                                                                               }
+                                                                               that.trigger("saveSuccess");
                                                                              }});
                 this.dirty = false;