There is a page with nested HTML select statements. Examples of how to bind selects in KnockoutJS assume the option values are in the view model. Here the options exist as HTML.
What syntax/functions would be used to bind the second select to the class name of the first select options so that they only appear in the second list when the corresponding class is selected? In other words, what would replace the space holder "whenStartAppGroupNSelected."
Markup :
<div class="apps">
<select id="startapp" name="startapp" data-bind="value: startapp">
<option value="value1" class="groupA">Some Val 1</option>
<option value="value2" class="groupB">Some Val 2</option>
<option value="value3" class="groupC">Some Val 3</option>
</select>
</div>
<div class="pages">
<select id="startpage" name="startpage" data-bind="value: startpage">
<option data-bind="visible: whenStartAppGroupASelected" value="path1" class="groupA">Page 1</option>
<option data-bind="visible: whenStartAppGroupBSelected" value="path2" class="groupB">Page 2</option>
<option data-bind="visible: whenStartAppGroupCSelected" value="path3" class="groupC">Page 3</option>
<option data-bind="visible: whenStartAppGroupCSelected" value="path4" class="groupC">Page 4</option>
</select>
</div>
Model :
myModel = function() {
var self = this;
self.startapp = ko.observable("").extend({required: true});
self.startpage = ko.observable("");
self.selectedApp = ko.computed(function() {
return self.startapp();
});
};