I think this is because your jQuery code is run before your template is rendered. You can use the afterRender callback provided in the template binding to enable enable the datepicker. Look at the documentation for more information and examples.
But an even better method to accomplish this, is to create a custom binding. Something like this:
ko.bindingHandlers.datepicker = {
init: function(element){
$(element).datepicker();
},
update: function(element) {
$(element).datepicker('refresh');
}
};
Then you can make text-input into a datepicker by doing this:
<input type="text" data-bind="datepicker:true" />
Read more about custom bindings here