Created
February 25, 2018 14:56
-
-
Save sansarun/5f6facf697b9e3de5c07d8fcc159c9e3 to your computer and use it in GitHub Desktop.
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
tumbons = [ | |
{"province":"Bangkok", "aumper": "thonburi", "tumbon": "klong san" }, | |
{"province":"Songkhla", "aumper": "hatyai", "tumbon": "swan neck" }, | |
{"province":"Songkhla", "aumper": "hatyai", "tumbon": "something" } | |
] | |
selectable_provinces = ko.computed(function(){ | |
return tumbons.map(e => e.province) | |
.distinct | |
}) | |
selectable_aumper = ko.computed(function(){ | |
return tumbons.filter(e => e.province == selected_province) | |
.map(e => e.aumper) | |
.distinct | |
}) | |
selectable_tumbons = ko.computed(function(){ | |
return tumbons.filter(e => e.province == selected_province && e.aumper == selected_aumper) | |
.map(e => e.tumbon) | |
.distinct | |
}) | |
<select id="province" data-bind="options: selectable_provinces, value: selected_province"/> | |
<select id="aumper" data-bind="options: selectable_aumper, value: selected_aumper"/> | |
<select id="tumbon" data-bind="options: selectable_tumbons, value: selected_tumbon"/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment