Created
August 16, 2012 08:41
-
-
Save tmeasday/3368472 to your computer and use it in GitHub Desktop.
Very basic reactive select for meteor
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
{{> select selectData}} | |
Template.foo.selectData = { | |
include_blank: true | |
icon: 'player' | |
name: 'players_required', | |
options: ({text: "#{i} players", value: i, selected: i == required} for i in [3..18]) | |
} |
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
Template.select.selected_text = -> | |
unless @selected_text? | |
selected_option = _.find(@options, (o) -> o.selected) | |
text = selected_option.text if selected_option | |
Meteor.deps.add_reactive_variable(this, 'selected_text', text) | |
@selected_text() | |
Template.select.events = | |
'change select': (event) -> | |
@selected_text.set($(event.target).find('option:selected').text()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment