Created
November 15, 2013 02:04
-
-
Save brian-mann/7477964 to your computer and use it in GitHub Desktop.
automating tagName's and columns for itemViews
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Views.CompositeView extends Marionette.CompositeView | |
itemViewEventPrefix: "childview" | |
itemViewOptions: (model, index) -> | |
options = {} | |
options.tagName = "tr" if @isTbody() | |
options.tagName = "li" if @isUl() | |
options.tableColumns = @$el.find("th").length if @isTbody() | |
options | |
isTbody: -> | |
@itemViewContainer is "tbody" | |
isUl: -> | |
@itemViewContainer is "ul" | |
class Views.CollectionView extends Marionette.CollectionView | |
itemViewEventPrefix: "childview" | |
itemViewOptions: (model, index) -> | |
options = {} | |
options.tagName = "li" if @tagName is "ul" | |
options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment