I am trying to push
the updated model
back to store
. i tried with couple of ways still getting failed.
Please help me to understand to push the model
back to store without updating backend
api.
here is my try:
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 );
}
},
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");
var updatedModel = JSON.parse(JSON.stringify(model));
updatedModel.type="card-list";
updatedModel.id="13";
console.log( "model would be:-" , updatedModel );
//sending just a updated model fails
let itemModel = this.store.push({'card-list': model });
//after stringfy trying to update still fails
let itemModel = this.store.push({'data': updatedModel });
// this.store.pushObject(JSON.parse(JSON.stringify(model)));
console.log( "store data", this.store.peekRecord('card-list', modelId ) )
this.transitionTo('cs2i.balance.balanceReview', {id:modelId});
}
}
});
What is wrong here? what is the correct way to put back the mode with updates?
Aucun commentaire:
Enregistrer un commentaire