Created
May 29, 2012 07:30
-
-
Save tmeasday/2823119 to your computer and use it in GitHub Desktop.
A really simple custom select widget implemented in Meteor
This file contains hidden or 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
| Session.set 'select.open', false | |
| Template.select.selected_value = -> Session.get('select.selected_value') | |
| Template.select.open = -> 'open' if Session.get('select.open') | |
| Template.select.selected = -> | |
| 'selected' if Session.equals('select.selected_value', this.valueOf()) | |
| Template.select.events = | |
| 'click li:not(:first-child)': (e) -> | |
| Session.set('select.selected_value', this.valueOf()) | |
| 'click': -> | |
| Session.set('select.open', !Session.get('select.open')) |
This file contains hidden or 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:not(.open) li:not(:first-child) { | |
| display: none; | |
| } |
This file contains hidden or 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 name="select"> | |
| <ul class="select {{open}}"> | |
| <li class="selected_value">{{selected_value}}</li> | |
| {{#each options}} | |
| <li class="{{selected}}"> | |
| {{this}} | |
| </li> | |
| {{/each}} | |
| </ul> | |
| </template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment