Basem
Basem

Reputation: 614

DatePicker format does not work if set by input element

I have observable objects that update the input values in real time. The problem is that the Kendo DatePicker does not know when the input value has been updated so none of the formatting takes place. A sample of this behavior can be seen here: http://jsfiddle.net/basememara/kMkSd/

$("#sampleDate1, #sampleDate2").kendoDatePicker({
    format: "dd MMM yyyy",
    parseFormats: ["yyyy/MM/dd"]
});
$("#sampleDate1").val('2012/09/25') //no formatting happens => 2012/09/25
$("#sampleDate2").data('kendoDatePicker').value('2012/09/25') //works => 25 Sep 2012

The DatePicker is expecting me to always update the value through the Kendo object. How to I tell the DatePicker that the input value has been updated (shouldn't this be done automatically though)?

Upvotes: 0

Views: 2932

Answers (1)

Cerbrus
Cerbrus

Reputation: 72857

This should re-trigger the formatting function:

$("#sampleDate2").data('kendoDatePicker').value($("#sampleDate2").val())
//Set the contents of #sampleDate2 to it's contents, through the kendoDatePicker

Upvotes: 3

Related Questions