adopted-ember-addons / ember-pikaday

A datepicker component for Ember CLI projects.
MIT License
158 stars 169 forks source link

Is the `value` 2-way binding still working on 2.X? #89

Closed hdra closed 8 years ago

hdra commented 8 years ago

Title question. I recently upgraded to 2.0.0 so that I'm able to clear the selected value, but I noticed that although I'm able to set the initial selected date, changing the date via Pikaday afterward doesn't change the bound value.

It is able to set the bound value to null when I clear the input though.

Is this an intended deprecation or is it a bug?

splattne commented 8 years ago

I think you can do it this way:

{{pikaday-input value=someDate onSelection=(action (mut someDate)) ... }}
stravid commented 8 years ago

2.X tries to follow Embers lead when it comes to Data Down - Actions Up. In this case it means the component can't change bounded values. You have to do it in your own action. (See @splattne answer for a shortcut.)

Clearing the input and setting the bound value to null seems like a bug. I'm currently swamped at work and will try to take a look as fast as possible.

stravid commented 8 years ago

Please re-open in case you have further questions.

jeffrey008 commented 7 years ago

@splattne Thanks for your solution. It works for me, but I am quite confused about what's happening there. AFAIK, value=someDate will set the default value of pikaday to someDay. When user selected a day, mut someDate will allow pikaday to modify someDay defined in the Controller. But how does it know what value should it change to?

Also I tried {{pikaday-input value=someDate onSelection=(action (mut someDate) value=target.value) ... }} but this doesn't work. I don't know why.