Knockout Example

Simple Knocout example

by KevinGabbert

HTML

<script src="http://cloud.github.com/downloads/SteveSanderson/knockout/knockout-1.2.0.js"></script>
<select data-bind="
        options: ServiceLines,
        optionsText :'Name',
        value: selectedServiceLine,
        optionsCaption: 'Select One'
">
</select>

<div data-bind="visible: selectedServiceLine">
    in <span data-bind = "text : selectedServiceLine().Name" class="result"></span> you are losing
</div>

<!--<div data-bind="visible: selectedServiceLine">
    Top Service Line Opportunity: <span data-bind = "text : selectedServiceLine().Name" class="result"></span>
</div>-->

JavaScript

$(document).ready(function () {

    //Temporary, until this gets hooked up properly KRG
    var serviceLinesModel = {
        ServiceLines: ko.observableArray([
             { Name: "Medicare P&L" },
             { Name: "Cardiology" },
             { Name: "Orthopedics" },
             { Name: "Pulmonology" },
             { Name: "Cardiac Surgery" },
             { Name: "Pediatrics" }
        ]),
        selectedServiceLine: ko.observable(),
        selectedModel: ko.observable()
    };

    ko.applyBindings(serviceLinesModel);

});