Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gbedardsice/d90967e7225400160022 to your computer and use it in GitHub Desktop.
Save gbedardsice/d90967e7225400160022 to your computer and use it in GitHub Desktop.
Backbone.Marionette Bubble Event
(function() {
'use strict';
/**
* Simple event bubbling callback generator.
* Usage:
*
* this.listenTo(view, 'some:event', Marionette.bubbleEvent('some:other:event'));
*
* @param {String} eventName The event name of the event triggered. Can be the
* same as the listened to event, or can be modified
* to fit your needs
* @return {Function} The callback function that does the actual event
* bubbling
*/
Marionette.bubbleEvent = function(eventName) {
return function() {
var args = _.toArray(arguments);
args.unshift(eventName);
this.trigger.apply(this, args);
};
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment