Apply reliable trigger to Backbone.Collection as well
FREEBIE
This commit is contained in:
parent
3e0fa995dd
commit
9dc406dc8d
1 changed files with 8 additions and 2 deletions
|
@ -111,7 +111,7 @@
|
||||||
// passed the same arguments as `trigger` is, apart from the event name
|
// passed the same arguments as `trigger` is, apart from the event name
|
||||||
// (unless you're listening on `"all"`, which will cause your callback to
|
// (unless you're listening on `"all"`, which will cause your callback to
|
||||||
// receive the true name of the event as the first argument).
|
// receive the true name of the event as the first argument).
|
||||||
Backbone.Model.prototype.trigger = Backbone.View.prototype.trigger = Backbone.Events.trigger = function(name) {
|
function trigger(name) {
|
||||||
if (!this._events) return this;
|
if (!this._events) return this;
|
||||||
var args = slice.call(arguments, 1);
|
var args = slice.call(arguments, 1);
|
||||||
if (!eventsApi(this, 'trigger', name, args)) return this;
|
if (!eventsApi(this, 'trigger', name, args)) return this;
|
||||||
|
@ -120,6 +120,12 @@
|
||||||
if (events) triggerEvents(events, name, args);
|
if (events) triggerEvents(events, name, args);
|
||||||
if (allEvents) triggerEvents(allEvents, name, arguments);
|
if (allEvents) triggerEvents(allEvents, name, arguments);
|
||||||
return this;
|
return this;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
Backbone.Model.prototype.trigger
|
||||||
|
= Backbone.View.prototype.trigger
|
||||||
|
= Backbone.Collection.prototype.trigger
|
||||||
|
= Backbone.Events.trigger
|
||||||
|
= trigger;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue