diff --git a/addon/mixins/controllers/saving.js b/addon/mixins/controllers/saving.js index 567beb2..fbe0723 100644 --- a/addon/mixins/controllers/saving.js +++ b/addon/mixins/controllers/saving.js @@ -32,15 +32,14 @@ export default Ember.Mixin.create( validateAndSave: function() { var _this = this; var runCustomValidations = _this.runCustomValidations; - var save = _this.save; var resolve = function() { Ember.assert( 'You need to specify a save method on this controller', - save + typeof _this.save === 'function' ); - save(); + _this.save(); }; var reject = function() { @@ -52,11 +51,7 @@ export default Ember.Mixin.create( if (runCustomValidations && !runCustomValidations.then) { Ember.assert('runCustomValidations() must return a promise (e.g. return new Ember.RSVP.Promise()).'); } else if (runCustomValidations) { - runCustomValidations().then(function() { - resolve(); - }, function() { - reject(); - }); + runCustomValidations().then(resolve, reject); } else { /* Else save with normal ember-validations checks */ diff --git a/tests/dummy/app/resources/posts/new/controller.js b/tests/dummy/app/resources/posts/new/controller.js index c3ba552..616a1f2 100644 --- a/tests/dummy/app/resources/posts/new/controller.js +++ b/tests/dummy/app/resources/posts/new/controller.js @@ -10,6 +10,10 @@ export default Ember.ObjectController.extend( } }, + save: function() { + console.log(this); + }, + cancel: function() { this.transitionToRoute('index'); }