Twipped / Kalendae

A javascript date picker that just works.
MIT License
1.99k stars 285 forks source link

Change event ordering #199

Open stell opened 7 years ago

stell commented 7 years ago

I got a problem when submitting a form which includes a picker. After selecting a date the form always submits with the date picket beforehand. What?? So in this minified example the first log outputs the picked date, but the second outputs the previously picked date. I need to post the form with the picked date of the element #picker.

How can i do that?

cal = new Kalendae.Input("picker", {
    selected: Kalendae.moment(),
    mode:'single',
    subscribe: {
      'change': function (date) {
          console.log(date, this.getSelected());
          console.log($('#picker').val());

          // call a js function which submits the form using the picked date value (not the previously picked one)
       }
    }
});