Skip to content

Instantly share code, notes, and snippets.

@rubiety
Last active January 1, 2016 16:39
Show Gist options
  • Save rubiety/8171932 to your computer and use it in GitHub Desktop.
Save rubiety/8171932 to your computer and use it in GitHub Desktop.
Collection-bound select list with Backbone Marionette
options = new Backbone.Collection([{id: 1, name: "Blue"}, {id: 2, name: "Green"}])
view = new SelectListView({ collection: options })
view.render()
class SelectListItemView extends Marionette.ItemView
tagName: "option"
template: _.template("<%= name %>")
onRender: -> @$el.attr("value", @model.get("id"))
class SelectListView extends Marionette.CollectionView
tagName: "select"
itemView: SelectListItemView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment