marionettejs/backbone.marionette — pull request #790 by lukesargeant (2013-11-22 23:18:22+00:00)
Title: addChildViewEventForwarding available from ItemView

When developing with Marionette, child item views forward their
events to their parent composite/collection view.

Sometimes there is the need to manually create a subview in an ItemView
or Layout and in this situation it would be great to be able to use
event forwarding in the same way.

This pull request allows addChildViewEventForwarding to be used by
custom code in ItemViews or Layouts to setup the same functionality
provided by default in collection/composite views.

For example:

var ItemViewWithForwarding = Marionette.ItemView.extend({
...
renderChildView: function(category) {
var view = new FormCategoryListItemView({
model: new Backbone.Model({category: category})
});

//Provide view reference and event prefix
this.addChildViewEventForwarding(view, "childview");
this.$('.event-actions').append(view.render().el);
}
});

Would love to hear feedback on this.