Closed Leooo closed 9 years ago
Good catch! Will put out a fix and update the documentation soon.
Also, I have a very strange behaviour while trying to use a "destroyHandler" in the corresponding view, that I'm totally unable to explain right now (posting this just in case you have an idea): when clicking the "Delete" button, this
is undefined in the destroyHandler
method. This is also the case in a submitHandler
method when clicking "Save". When calling the methods from the console, this
is properly defined so this must come from the Submitting
mixin implementation !?
=> Using ember 1.11 on ember-cli
import Ember from 'ember';
import Submitting from 'ember-easy-form-extensions/mixins/views/submitting';
export default Ember.View.extend(Submitting,{
templateName: 'profile/feedback/education/edit',
classNames: '',
submitHandler: function() {
log(this);//undefined when called through mixin??
return new Ember.RSVP.Promise(function(resolve, reject) {
//if (!this.get('someViewProperty')) {
//reject(); // Resets the form submission state
//} else {
resolve(); // Will call the controller method
//}
});
},
destroyHandler: function() {
//https://github.com/sir-dunxalot/ember-easy-form-extensions/issues/18
log(this);//undefined when called through mixin??
var self=this;
return new Ember.RSVP.Promise(function(resolve, reject) {
self.get('controller')["destroyModel"]();
reject();
});
},
});
Which version of easy-form-extensions are you using? That was a bug a while back but was fixed. It may be that a contribution brought it back. Shouldn't be hard to fix.
0.2.8
Couldn't understand on my side why this
was not defined so I overrode the mixin in an initializer for now.
destroy
to delete
.
See http://emberjs.com/api/classes/Ember.Controller.html#method_destroy
The method is always called after saving the form (at least as long as we switch template without transitioning and the controller is destroyed). Probably another name instead of "destroy" should be used for the destroy-submission process.