Last active
January 1, 2016 16:39
-
-
Save rubiety/8171932 to your computer and use it in GitHub Desktop.
Collection-bound select list with Backbone Marionette
This file contains 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
options = new Backbone.Collection([{id: 1, name: "Blue"}, {id: 2, name: "Green"}]) | |
view = new SelectListView({ collection: options }) | |
view.render() |
This file contains 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 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