Created
August 15, 2013 14:36
-
-
Save proxygear/6241315 to your computer and use it in GitHub Desktop.
A select with marionette JS ?
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
ES.module 'Views', (Views, App, Backbone, Marionette, $, _)-> | |
class Views.Select extends Marionette.ItemView | |
template: JST['select'] | |
ui: | |
select: 'select' | |
events: | |
'change select': 'selected' | |
initialize: (options)-> | |
@listenTo @model, 'reset', this.display, this | |
@selected = options.selected | |
display: ()-> | |
this.ui.select.find('option').remove() | |
this.ui.select.append("<option value=''-> Pick one</option>") | |
for opt in @model.models | |
this.ui.select.append("<option value='#{opt.get('_id')}'>#{opt.get('name')}</option>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And more simplicity:
Usage