javascript - Knockout.js input type date data binding in Google Chrome -


i'm struggling set value on input of type="date" in google chrome: http://jsfiddle.net/ruslans/gnv7h/

<input data-bind="value: datestring" type="date"></input>  var viewmodel = {     somedate: new date(parseint("/date(1367708400000)/".substr(6))) }; ko.applybindings(viewmodel); 

my date come json data first need find out format need in chrome's date picker recognize binding. have jquery selector , set .val() on field? seems daft...

edit: according this article, date format set value on google date input must "yyyy-mm-dd". pitty, because we're using jquery date picker browsers there's no native date pickers exist.

you need correctly format value described in w3c working draft:

a valid full-date defined in rfc 3339, additional qualification year component 4 or more digits representing number greater 0.

example: 1996-12-19

so following should work:

var viewmodel = {         datestring: ko.observable('2002-02-02') }; 

demo jsfiddle.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -