documentcloud/backbone — pull request #2053 by eastridge (2012-12-30 04:04:54+00:00)
Title: Add isPopulated and shouldFetch methods

This adds `isPopulated` and `shouldFetch` methods to `Backbone.Collection` and `Backbone.Model`, the behaviors implemented are:

- `collection.isPopulated()`: Has the collection been initialized with any models, or been fetched from the server, but the response has no models.
- `collection.shouldFetch()`: The collection should be fetched if it has a url but is not populated.
- `model.isPopualted()`: Have any non default keys been set on the model?
- `model.shouldFetch()`: If we have a url and are not populated we should fetch

In support these additions `Backbone.Model.prototype.url` now accepts a `{silent: bool}` argument to surpress the `urlError`. This defaults to false, so the previous behavior is preserved by default.