Open silverqx opened 9 years ago
So I have resolved it with Deffered.
Wait and see if you have a better solution, before closing this issue.
import Em from "ember";
var _asyncSubmitDeffer = Ember.RSVP.defer();
export default Em.Controller.extend({
actions: {
submit: function() {
var model = this.get('model');
if (model.get('isDirty')) {
model.save().then((data) => {
_asyncSubmitDeffer.resolve();
this.transitionToRoute('users')
}).catch(function (reason) {
_asyncSubmitDeffer.reject('Server error...');
}).finally(() => {
});
} else {
_asyncSubmitDeffer.resolve();
}
},
asyncSumbit: function(setPromise) {
return setPromise(_asyncSubmitDeffer.promise);
}
}
});
Hi,
I want to ask, how to use this async button as submit button with ember-idx-forms?
Because when I click on async button, so first is called action, which is defined on on-click property and after that is called submit method at https://github.com/indexiatech/ember-forms/blob/master/addon/form.js#L52 and after that is called submit handler in the controller or route.
If you have ready some working example, pls paste it here.
Thank you for advices.