Skip to content

Instantly share code, notes, and snippets.

@akiray03
Created January 19, 2014 05:51
Show Gist options
  • Select an option

  • Save akiray03/8500931 to your computer and use it in GitHub Desktop.

Select an option

Save akiray03/8500931 to your computer and use it in GitHub Desktop.
// Fetch the default set of models for this collection, resetting the
// collection when they arrive. If `reset: true` is passed, the response
// data will be passed through the `reset` method instead of `set`.
fetch: function(options) {
options = options ? _.clone(options) : {};
if (options.parse === void 0) options.parse = true;
var success = options.success;
var collection = this;
options.success = function(resp) {
var method = options.reset ? 'reset' : 'set';
collection[method](resp, options);
if (success) success(collection, resp, options);
collection.trigger('sync', collection, resp, options);
};
wrapError(this, options);
return this.sync('read', this, options);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment