Skip to content
This repository was archived by the owner on Mar 20, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,10 @@ A template name or template function to use when rendering each model. If using

A view class to be initialized for each item. Can be used in conjunction with `itemTemplate`.

### itemAttributes *view.itemAttributes*

Attributes that will be passed to the constructor of each item. Can be used in conjunction with `itemView`.

### itemContext *view.itemContext(model, index)*

A function in the declaring view to specify the context for an `itemTemplate`, receives model and index as arguments. `itemContext` will not be used if an `itemView` is specified as the `itemView`'s own `context` method will instead be used.
Expand Down Expand Up @@ -1049,6 +1053,7 @@ When rendering `this.collection` many properties will be forwarded from the view
- `itemView`
- `itemContext`
- `itemFilter`
- `itemAttributes`
- `emptyTemplate`
- `emptyView`
- `loadingTemplate`
Expand Down
8 changes: 7 additions & 1 deletion src/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,13 @@ Thorax.CollectionView = Thorax.View.extend({
if (this.itemTemplate) {
viewOptions.template = this.itemTemplate;
}
return Thorax.Util.getViewInstance(this.itemView, viewOptions);
if (!this.itemAttributes) {
this.itemAttributes = {};
}

var itemAttributes = _.extend(this.itemAttributes, viewOptions);

return Thorax.Util.getViewInstance(this.itemView, itemAttributes);
} else {
// Using call here to avoid v8 prototype inline optimization bug that helper views
// expose under Android 4.3 (at minimum)
Expand Down