Closed Prinzhorn closed 10 years ago
I had this problem too, I worked around it by overriding the itemView in my initialize function like this (if you didn't think of it already):
initialize: function() {
// ...
var self = this;
this.itemView = function(options) {
options.collectionView = self;
return new MyChildVIew(options);
}
}
I agree this should be passed by default, in the same way Backbone.Collection sets the collection
attribute on its models. I also had the reverse problem (which I'll do my best to fix if I'm allowed to do what I said in #83)
Thanks, I didn't thought about that since I worked around it (I don't quite remember on what I was working six days ago o_O).
Sure, you've got it... added in commit 2eef8b4. An item view instance now receives a collectionView
option when constructed. You may choose to persist that initialize option on the item view if you need it.
Awesome, thanks!
I fear you haven't tested it. Inside the each
iterator function (https://github.com/gmac/backbone.epoxy/commit/2eef8b4921056d33735842d413f6087c481bc636#diff-56c53ff52b21a50cf38a0d0ffd2776c0R680) this
refers to the window
, making this.view
undefined, resulting in collectionView
being undefined as well.
I came across multiple situations where I wished I could access the parent view (list) from within an itemView (list item).
Does this make sense? Maybe pass it to the
itemView
constructor ascollectionView
option.