Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with binding #129

Open
gusdecool opened this issue Aug 8, 2016 · 3 comments
Open

Doesn't work with binding #129

gusdecool opened this issue Aug 8, 2016 · 3 comments

Comments

@gusdecool
Copy link

<paper-date-picker date="[[ date ]]"></paper-date-picker>

for example date is binding and the value is 2016-12-01
it will give error:

Invalid date: undefined
paper-calendar.html:617 Invalid date: 2016-12-01

repeated like ~1.000 times

@web-padawan
Copy link

web-padawan commented Aug 8, 2016

I can reproduce this. My current workaround is using two properties (via wrapper component), one for outer change (called date), other for inner (called value):

properties: {
    date: {
        type: String,
        notify: true,
        observer: '_onDateChanged'
    },
    value: {
        type: String
    }
},
_onDateChanged: function (date) {
    // when date is set from <paper-input>, update datepicker
    var input = Date.parse(date);
    if (!isNaN(input)) {
        // not a NaN means a valid date string
        var upd = new Date(input);
        // <paper-date-picker> resets hours, so we need to do the same
        // https://github.com/bendavis78/paper-date-picker/issues/50        
        upd.setHours(0);
        // only update value if it has changed
        if (this.value !== upd) {
            this.value = upd;
        }
    }
},

Not sure, but it's likely that Date.parse() could be called by this component itself here.

@bendavis78 WDYT?

@diegocerdan
Copy link

I have the same problem and can't bind date, min-date or max-date.

Strangely enough the example from README.md reads:
<paper-date-picker id="picker" date="[[date]]"></paper-date-picker>

So the binding is supposed to work.

@admwx7
Copy link
Collaborator

admwx7 commented Sep 18, 2017

I'm not having this issue, but if you can recreate the problem using something like JSFiddle @diegocerdan I might be able to fix it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants