From 9dc406dc8ddbea43df1819fe34f284f7bcda56cc Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 21 Jul 2017 11:48:54 -0700 Subject: [PATCH] Apply reliable trigger to Backbone.Collection as well FREEBIE --- js/reliable_trigger.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/reliable_trigger.js b/js/reliable_trigger.js index 1b8cd06e0..fb49ba47f 100644 --- a/js/reliable_trigger.js +++ b/js/reliable_trigger.js @@ -111,7 +111,7 @@ // passed the same arguments as `trigger` is, apart from the event name // (unless you're listening on `"all"`, which will cause your callback to // 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; var args = slice.call(arguments, 1); if (!eventsApi(this, 'trigger', name, args)) return this; @@ -120,6 +120,12 @@ if (events) triggerEvents(events, name, args); if (allEvents) triggerEvents(allEvents, name, arguments); return this; - }; + } + + Backbone.Model.prototype.trigger + = Backbone.View.prototype.trigger + = Backbone.Collection.prototype.trigger + = Backbone.Events.trigger + = trigger; })();