datetimepicker sets date to todays date on when clicking outside

谁说我不能喝 提交于 2019-12-02 04:01:46

问题


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 very minimal options set, it automatically sets the date field to todays date when i click outside without selecting a date.

Anyone have an idea whats going on?

This is my code:

$('input.datetime').datetimepicker({
        ampm: true,
        timeFormat: 'hh:mm tt',
        addSliderAccess: true,
        sliderAccessArgs: { touchonly: false },
     });

Appreciate all the help I can get, its causing some confusion for my staff using the application...


回答1:


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);
                    }
     });


来源:https://stackoverflow.com/questions/10827605/datetimepicker-sets-date-to-todays-date-on-when-clicking-outside

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!