I am trying to update my mode just only store without connecting backend. after it's done successfully I will retrive the updated model using it's id.
for that, I am trying to push my model to store ( updating the existing model in store ) but getting error.
any one hlpe me?
here is my code :
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
if(this.store.hasRecordForId('card-list', params.id)){
return this.store.peekRecord('card-list', params.id );//getting
}
},
actions:{
formValidateBeforeNext:function(){
var model = this.controllerFor(this.routeName).get('model');
var modelId = this.controllerFor(this.routeName).get('model').get("id");
var oneTimeFee = this.controllerFor(this.routeName).get('model').get("oneTimeFee");
var monthlyInstalmentAmount = this.controllerFor(this.routeName).get('model').get("monthlyInstalmentAmount");
console.log( "model would be:-" , JSON.parse(JSON.stringify(model)) );
this.store.push(JSON.parse(model));//updating without connect to backend,but throws error
console.log( "store data", this.store.peekRecord('card-list', modelId ) )
this.transitionTo('cs2i.balance.balanceReview', {id:modelId});
}
}
});
Aucun commentaire:
Enregistrer un commentaire