I'm trying to render a View which needs to know the index position of the Model passed in inside its Collection:
Parent View
collection.each(function($_v, $_k) {
(new view({model: $_v, index: $_k})).render();
});
Child View
className: function() {
0 === this.index % 2 ? 'colored' : '';
}
However it appears that this.index
can't be set this way and become undefuined
. What is the proper to make this work?
I think it should be:
className: function() {
0 === this.options.index % 2 ? 'colored' : '';
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.