When I use a pikaday field with no special options, I get "Invalid date" in the field.
I can see the good value for a fraction of a second but then it get replaced by this message.
This problem don't appear with the dev environment, and I suspect it has something to do with Moment.js (or the lack of it to be precise).
I experimented a bit with format, but nothing change that.
For now I will send a PR which don't add any default values (except field) in pikadayOptions.
Could you make a fiddle with this issue?
Found more things:
String :arrow_right: "Invalid date" appear in the fieldString in the same format defined :arrow_right: the date appear into the field but at first (without any interaction) the format is not respected (eg. "Thu Sep 01 2016" instead of "2016-09-01"). When a value is selected, for a split second the non formatted value appear then the good format replace it.Object :arrow_right: the date appear into the field but at first (without any interaction) the format is not respected (eg. "Thu Sep 01 2016" instead of "2016-09-01"). When a value is selected, for a split second the non formatted value appear then the good format replace it.So, even when the format is good or with an empty Object, the first value is not respecting the desired format, and this undesired format still appear for a split second.
We might need to capture the click events and stop propagation or use onSelect callback to launch formatValueToField. Also maybe launch picker.setDate('2015-01-01') (or picker.setMoment(moment('14th February 2014', 'DDo MMMM YYYY'))) at the ready hook just after initialization.
What do you think ?
EDIT: When Moment.js is loaded, no more problem. Is Moment.js required for Pikaday?
They say:
No dependencies (but plays well with Moment.js)
I know, but try to remove moment.js from the dev test files and use Pikaday to select a date. You will get "Invalid date". This may not be our fault, because I don't see where we use it without importing it first.
What do you think we should do ? Change the documentation ? Try to find and correct the bug ?
For quick solution please add the momentjs to pikaday as dependencies in the documentation. If I have more time, I will try to find the exact problem.
I edited the doc and pointed to this issue
Maybe it is fixed in #118 and momentjs removed and pikaday working.