Binding visibility to expression in knockout

http://stackoverflow.com/questions/7719359/using-nested-knockout-templates-to-display-nested-data

by Hari Menon

HTML

<script src="https://github.com/SteveSanderson/knockout/raw/version-2-2-1/build/output/knockout-latest.debug.js"></script>
<select data-bind="options: types, value: type"></select>
<hr/>
<span data-bind="visible: isType('a')">a</span>
<span data-bind="visible: isType('b')">b</span>
<span data-bind="visible: isType('c')">c</span>

JavaScript

var viewModel = {
    types: ["a", "b", "c"],
    type: ko.observable(),
    isType: function(type) {
       return type === this.type();   
    }
};

ko.applyBindings(viewModel);