Skip to content

Instantly share code, notes, and snippets.

@sgharms
Created January 13, 2012 16:45
Show Gist options
  • Save sgharms/1607438 to your computer and use it in GitHub Desktop.
Save sgharms/1607438 to your computer and use it in GitHub Desktop.
BB reset documentation
reset collection.reset(models, [options])
Adding and removing models one at a time is all well and good, but
sometimes you have so many models to change that you'd rather just
update the collection in bulk. Use reset to replace a collection with a
new list of models (or attribute hashes), triggering a single "reset"
event at the end. Pass {silent: true} to suppress the "reset" event.
Using reset with no arguments is useful as a way to empty the
collection.
Here's an example using reset to bootstrap a collection during
initial page load, in a Rails application.
<script>
Accounts.reset(<%= @accounts.to_json %>);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment