mardi 12 janvier 2016

Not to use pushPayload in ember

I have to store a data from ajax call to model.Now I am using "pushPayload" to save the data to my model.But it is throwing error

serializer.pushPayload is not a function

In controller I am doing something like this after the ajax call.

currentState.store.pushPayload('discover',result)

serializer (discover.js)

export default DS.JSONSerializer.extend(DS.EmbeddedRecordsMixin,{
isNewSerializerAPI: true,
  primaryKey:'pk',
  normalize: function(typeClass, hash) {
    var fields = Ember.get(typeClass, 'fields');
    fields.forEach(function(field) {
      var payloadField = Ember.String.underscore(field);
      if (field === payloadField) { return; }
      hash[field] = hash[payloadField];
      delete hash[payloadField];
    });
    return this._super.apply(this, arguments);
  }
  });

How do I save the data recieved from server to my model.The reponse is an array of object

Aucun commentaire:

Enregistrer un commentaire