@gjhawar wrote:
Hello,
In my router I am trying to save the elements in an array, but I only want to do that if the underlying model has changed.
import Ember from 'ember'; export default Ember.Route.extend({ model(){ return Ember.RSVP.hash({ author : this.modelFor('account').author, countries : this.modelFor('account').countries, regions : this.modelFor('account').regions }); }, setupController(controller){ this._super(...arguments); let authorsCollection = this.modelFor('account.company-info').author; controller.set('companys', authorsCollection.filter(function (item) { return item.get('Type.TypeId') === 2; }) ); controller.set('inInformationComplete', this.modelFor('account.company-info').authors.get('inInformationComplete')); }, actions : { submit(isValid){ let companys = this.controller.get('companys'); companys.forEach(function(item){ item.save(); }); console.log("in route isValid : " + isValid); } } });
//
So here can I save companys.forEach(function(item){ the item only when something has changed. Should that logic be in the adapter?
Posts: 1
Participants: 1