Cancelling adding an indexer will stop listening to save event

Fixed: Cancelling adding indexer will not break saving
pull/2/head
Mark McDowall 11 years ago
parent 1cae7293e7
commit cc66077943

@ -1,5 +1,5 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<button type="button" class="close x-cancel"aria-hidden="true">&times;</button>
{{#if id}}
<h3>Edit</h3>
{{else}}
@ -42,7 +42,7 @@
<span class="x-activity"></span>
<button class="btn" data-dismiss="modal">cancel</button>
<button class="btn x-cancel">cancel</button>
<div class="btn-group">
<button class="btn btn-primary x-save">save</button>

@ -18,7 +18,8 @@ define(
events: {
'click .x-save' : '_save',
'click .x-save-and-add': '_saveAndAdd'
'click .x-save-and-add': '_saveAndAdd',
'click .x-cancel' : '_cancel'
},
initialize: function (options) {
@ -68,6 +69,13 @@ define(
self.ui.activity.empty();
});
}
},
_cancel: function () {
if (this.model.isNew()) {
this.model.destroy();
vent.trigger(vent.Commands.CloseModalCommand);
}
}
});

@ -10,6 +10,7 @@ define(
initialize: function () {
this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings);
this.listenTo(this, 'destroy', this._stopListening);
},
saveSettings: function () {
@ -28,8 +29,11 @@ define(
}
return undefined;
}
},
_stopListening: function () {
this.stopListening(vent, vent.Commands.SaveSettings);
}
});
return AsChangeTrackingModel.call(model);

Loading…
Cancel
Save