Drop down selection changed event

https://groups.google.com/d/topic/knockoutjs/U8LA3u4ktTk/discussion

by Keyur Patel

HTML

<script src="http://rniemeyer.github.com/KnockMeOut/Scripts/jquery.tmpl.js"></script>
<script src="http://knockoutjs.com/downloads/knockout-2.2.1.debug.js"></script>
<select data-bind="options: choices, value: selectedChoice"></select>
<hr />
<select data-bind="event: { change: selectionChanged }">
    <option>A</option>
    <option>B</option>
    <option>C</option>
</select>

JavaScript

var viewModel = {
    choices: ["one", "two", "three"],
    selectedChoice: ko.observable("two") ,
    selectionChanged: function(event) {
         alert("the other selection changed");  
    } 
};

viewModel.selectedChoice.subscribe(function(newValue) {
   alert("the new value is " + newValue); 
});


ko.applyBindings(viewModel);