I would like to access the app.vent from Marionette.ItemView.
Maybe an option could be to pass a parameter (app.vent
) to Marionette.ItemView
from Marionette.CompositeView
.
Here my code:
// view/compositeView.js
define([
'marionette',
'views/item'
], function (Marionette, itemView) {
var ListView = Marionette.CompositeView.extend({
itemView: itemView
});
});
Any ideas?
P.S.:
I cannot access the app from itemView because there is a problem of circular dependency.
app -> view/compositeView -> view/itemView
v0.9 added an
itemOptions
attribute that can be used for this. It can either be an object literal or a function that returns an object literal.All of the
key: "value"
pairs that are returned by this attribute will be supplied to the itemview's options in teh initializerAdditionally, if you need to run specific code for each itemView instance that is built, you can override the
buildItemView
method to provide custom creation of the item view for each object in the collection.For more information, see:
Since Marionette v2.0.0, childViewOptions is used instead of itemViewOptions to pass parameters to the child view:
But to work with events, lets use Marionette.Radio instead of passing app.vent to the view.