bootstrap datepicker

http://stackoverflow.com/questions/11121960/bootstrap-datepicker-with-knockout-js-databind

by kougiland

HTML

<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="http://knockoutjs.com/downloads/knockout-2.2.1.js"></script>
<link rel="stylesheet" href="https://rawgithub.com/Aymkdn/Datepicker-for-Bootstrap/master/datepicker.css">
<script src="http://makingsense.github.io/moment-datepicker/Scripts/moment.js"></script>
<script src="http://makingsense.github.io/moment-datepicker/moment-datepicker/moment-datepicker.js"></script>
<script src="http://makingsense.github.io/moment-datepicker/moment-datepicker/moment-datepicker-ko.js"></script>
<div id='target'>
    <input id="fromdate" data-bind='datepicker: test_date'/>
    
</div>

CSS

#target {
  margin: 2em;
}

JavaScript

var model = {
    test_date: ko.observable(new Date())    
};

ko.applyBindings(model, $("#target")[0]);

model.test_date.subscribe(function (newValue) {    
   
   // alert("new selection :" + newValue);
});