fooloomanzoo / datetime-picker

A minimal picker for date and time for Polymer, that can use the native input
MIT License
78 stars 18 forks source link

[ASK] Set time-picker confirmedTime #26

Closed alkunjo closed 6 years ago

alkunjo commented 6 years ago

I'm a bit confused on how to set confirmedTime of a time-picker. I have 2 cases to set the confirmedTime.

  1. First I want to set the default confirmedTime on page load or on custom-element load

    • I had tried this way but it doesn't work
      <time-picker confirmed-time="09:00:00.000" time="09:00:00.000" clamp="seconds" id="mondayOpeningHour"></time-picker>
    • I also had tried to set it on element ready() and/or connectedCallback() like below and that doesn't work too
      ready(){
      super.ready()
      this.$.mondayOpeningHour.confirmedTime = "09:00:00.000"
      }

      Then how to set it by default?

  2. Second, I want to set the confirmedTime with data binding on Polymer 2. I got the data from an iron-ajax and I tried to passed it in 2 ways that both don't work

    • I set it through the element
      <time-picker confirmed-time="[[data.mondayOpening]]" time="[[data.mondayOpening]]" clamp="seconds" id="mondayOpeningHour"></time-picker>
    • I set it on data load function
      onDataLoad(){
      this.$.mondayOpeningHour.confirmedTime = this.data.mondayOpening
      }

      On 2nd case, I had debugged the data by printing it on a div and it shows. For both cases, where is my mistakes so the confirmedTime is not set?

fooloomanzoo commented 6 years ago

There were a lot of changes related to the initial values. If you try https://codepen.io/fooloomanzoo/pen/jYzvgg does this fix this issue?

alkunjo commented 6 years ago

hai @fooloomanzoo, thanks for your response. I actually had already found the answer like a week ago and forgot to close the issue. I found that using confirmedDatetime properties are the best approach so far. I also can preset the value from iron-ajax response data binding or even change it dynamically by webcomponent event. So I'll close the issue. Thanks :+1: :+1: