-
-
Save onerinas/12adcc6439e381ada59ee8aab52f8156 to your computer and use it in GitHub Desktop.
Mithril: Dropdowns (select boxes)
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 DropDownExample = { | |
controller: function () { | |
var ctrl = this | |
ctrl.data = m.prop([{ name: 'alice', id: 1}, { name: 'bob', id: 2 }]) | |
ctrl.selectedId = m.prop() | |
}, | |
view: function (ctrl) { | |
return m('select', { onchange: m.withAttr('value', ctrl.selectedId) }, [ | |
ctrl.data().map(function(person) { | |
return m('option', { value: person.id }, person.name) | |
}) | |
]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment