datetimepicker sets date to todays date on when clicking outside

后端 未结 1 1987
我寻月下人不归
我寻月下人不归 2021-01-21 16:58

I have searched high and low for the answer to this issue, but no luck so now I have to ask...

I have the datetimepicker from Trent Richardson, and for some reason with

相关标签:
1条回答
  • 2021-01-21 17:14

    i searched high and low too, but after putting a few debug messages, the answer was obvious. What I noticed is that the onClose method has a "value" parameter which has the actual date which you select OR if you select nothing, it has the original value from your textbox. Set it as the value of the inputbox and walaaaa! problem solved.

    If you don't do this, the current date will replace your original date when you just want to close the datetimepicker.

    $('input.datetime').datetimepicker({
            ampm: true,
            timeFormat: 'hh:mm tt',
            addSliderAccess: true,
            sliderAccessArgs: { touchonly: false },
            onClose: function (value) {
                            $('input.datetime').val(value);
                        }
         });
    
    0 讨论(0)
提交回复
热议问题