Skip to content

Instantly share code, notes, and snippets.

@brian-mann
Created October 10, 2013 18:21
Show Gist options
  • Select an option

  • Save brian-mann/6923050 to your computer and use it in GitHub Desktop.

Select an option

Save brian-mann/6923050 to your computer and use it in GitHub Desktop.
Clever trick to automate children tagName based on their parent's element
class Views.CompositeView extends Marionette.CompositeView
itemViewEventPrefix: "childview"
itemViewOptions: (model, index) ->
options = {}
options.tagName = "tr" if @itemViewContainer is "tbody"
options
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