The restful api im calling wraps the desired payload (of models) within 'Payload'
I can ONLY get it to work this way, by 1. adding each into this.add(model) and 2. returning the array
Note: 'this' is a Backbone Collection
parse: function(resp, xhr) {
var that = this;
var ourPayload = resp.Payload;
ourPayload.forEach( function(model) { that.add(model);} );
return ourPayload;
},
In all examples I'd expect to simply do
parse: function(resp, xhr) {
return resp.Payload;
}
The format of the rest api is "{"Success":"true", ...., "Payload":[{model},{model},{model}], .... }
Can one explain the need to the collection.add(model)