I ran into this problem with ember data. I would like it to be paymentMethodDidChangecalled only after the payment has been initialized, but paymentMethodDidChangecalled several times.
When the payment isDirty, I save the object to the backend, but I can not do it this way, because it paymentMethodDidChangestarts when it is payment_methodinstalled, even if it has not changed.
How to configure an observer to belongsTonot trigger until a relationship is built?
App.Payment = DS.Model.extend({
amount: DS.attr('number'),
payment_method: DS.belongsTo('payment_method'),
paymentMethodDidChange: (function() {
if (!Em.isEmpty(this.get('payment_method')) {
this.send('becomeDirty');
}
}).observes('payment_method').on('init')
})
source
share