mercredi 9 août 2017

How to keep the data on refresh a page?

I am getting my data from the model. after the model integrated to page, when I refresh the page the data goes away.

I would like to prevent the data still on refresh. what is the correct way to do this in EmberJs any one show me the correct way to prevent my data from refresh?

my model code :

export default Ember.Route.extend({
  model: function(params) {
    return this.store.peekRecord('card-list', params.id ); //works
  }
});

Thanks in advance.

UPDATE

    import Ember from 'ember';

    export default Ember.Route.extend({
      model: function(params) {

        if(this.store.hasRecordForId('card-list', params.id)){
            return Ember.RSVP.hash({
                model: this.store.peekRecord('card-list', params.id ) 
            })
        }
    //I am trying for refresh. but throws error as
//Error while processing route: cs2i.balance.balanceEdit Ember Data Request GET /api/card-lists/4196074912005007 returned a 404
        return Ember.RSVP.hash({
            model: this.store.findRecord('card-list', params.id ) 
        })
      }
    });




Aucun commentaire:

Enregistrer un commentaire