Created
June 4, 2014 15:28
-
-
Save gbedardsice/d90967e7225400160022 to your computer and use it in GitHub Desktop.
Backbone.Marionette Bubble Event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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