Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Add itemView instead of getView in CollectionView. #106

Merged
merged 1 commit into from
Jun 13, 2012

Conversation

paulmillr
Copy link
Contributor

This would make stuff more Backbony.

@karellm review please

# Was.
class UsersView extends CollectionView
  getView: (model) ->
    new UserView({model})

# Now.
class UsersView extends CollectionView
  itemView: UserView

# Or even.
users = new Collection null, {model: User}
usersView = new CollectionView {collection: users, itemView: UserView}

@molily
Copy link
Member

molily commented Jun 13, 2012

Good idea, keeps simple use cases easy. The user can still override getView if a more complicated algorithm is needed.

paulmillr added a commit that referenced this pull request Jun 13, 2012
Add itemView instead of getView in CollectionView.
@paulmillr paulmillr merged commit 6693e63 into master Jun 13, 2012
if @itemView?
new @itemView({model})
else
throw new Error 'CollectionView#itemView must be overridden'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably change this error message to the itemView property must be defined (or the getView must be overridden) or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done @ 7852b76

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants