lundi 25 mai 2015

ember manually updateRecord - getting the URL

I need to override updateRecord and extract a specific data field to POST. How do I get the url (host) in an adapter? (the documentation is really scarce...)

The code:

  updateRecord: function(store, type, snapshot) {
    var data = this.serialize(snapshot, { includeId: true });
//  url = ..... // I want to have it: '<host>/my addition'
    return new Ember.RSVP.Promise(function(resolve, reject) {
      Ember.$.ajax({
        type: 'POST',
        url: url,
        dataType: 'json',
        data: data
      }).then(function(data) {
        Ember.run(null, resolve, data);
      }, function(jqXHR) {
        jqXHR.then = null; // tame jQuery's ill mannered promises
        Ember.run(null, reject, jqXHR);
      });
    });
  }




Aucun commentaire:

Enregistrer un commentaire