Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- save: function(){
- var url = "/api/v1/player_evaluations";
- var recordType = "player_evaluation";
- var topLevelKey = `${recordType}s`;
- var itemsToSave = this.get('myItems');
- var store = this.get('store');
- var type = "post";
- var dataType = "json";
- var contentType = "application/json; charset=utf-8";
- var recordCollection = Ember.A();
- for(var i = 0; i < itemsToSave.length; i++) {
- recordCollection.push store.createRecord(recordType, itemsToSave[i]);
- }
- var paylaod = {}
- var paylaod[topLevelKey] = recordCollection.map(function(record) { record.serialize() });
- var data = JSON.stringify(payload);
- Ember.$.ajax({ url, type, dataType, data, contentType }).then function(data) { store.pushPayload recordType, data }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement