Skip to content

Instantly share code, notes, and snippets.

@brian-mann
Created November 15, 2013 02:04
Show Gist options
  • Save brian-mann/7477964 to your computer and use it in GitHub Desktop.
Save brian-mann/7477964 to your computer and use it in GitHub Desktop.
automating tagName's and columns for itemViews
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