Atomic Spin has a great article on setting up Pikaday with an Ember.TextField view.
However, since I'm using Ember Data with some date attributes, I needed to actually use a Date object rather than a formatted date string. Here's what I came up with after adding a few things to their example:
There were a couple things I had to add for this to work:
- I'm using the moment.js library to allow
MM/DD/YYYYformatting. - I format the existing date in the
didInsertElementevent handler. - Rather than binding the attribute directly to the
value, I'm using adatebinding instead. This gives me the chance to parse a formatted date before setting the attribute. - Two-way binding to the date:
- The
updateDatefunction, which observesvalue, directly sets thedateto the parsed value. - The
updateValuefunction, which observesdate, updates thevaluewith the formatted date.
- The