documentcloud/backbone — pull request #1686 by tgriesser (2012-09-29 15:44:07+00:00)
Title: Checking that model.trigger is a function to make Backbone.sync more flexible

Before the `success` & `error` handlers were consolidated into `Backbone.sync` - it was possible (albeit undocumented) functionality to use `Backbone.sync` standalone with a plain javascript object as the second argument - rather than a `Model` or `Collection`, as a convenient wrapper for `$.ajax` calls:

Backbone.sync('save', obj, {
url : '/path/to/url',
success : function () {
// success
},
error : function () {
// error
}
});

While undocumented, I found it to be a nice feature to standardize an `$.ajax` wrapper to use stand-alone, in one-off cases where creating a model or collection seemed overkill. So I'm suggesting adding a `_.isFunction` check before the `trigger` call, so the `Backbone.sync` can continue to be used in this fashion.