Created
April 3, 2014 10:47
-
-
Save thehydroimpulse/9952273 to your computer and use it in GitHub Desktop.
View
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
<div class="ui dropdown"> | |
<button class="ui button" type="button" data-title="title"> | |
{{selected ? selected : default}} | |
</button> | |
<ul class="ui dropdown-list"> | |
<li data-each="item in list" data-click="select(@id)">{{item.name}}</li> | |
</ul> | |
</div> |
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
var view = require('view'); | |
var template = require('./template'); | |
var Dropdown = view() | |
.use(view.compile(template)) | |
.scope(function(scope, props) { | |
scope.selected = null; | |
scope.default = props.default | |
scope.list = props.list; | |
}); | |
Dropdown.prototype.select = function(id, scope) { | |
scope.selected = scope.list[id]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment