datetimepicker在点击外部时将日期设置为今天的日期 [英] datetimepicker sets date to todays date on when clicking outside

查看:104
本文介绍了datetimepicker在点击外部时将日期设置为今天的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了这个问题的答案的高低,但没有运气所以现在我要问...

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

我有来自Trent Richardson的日期时间选择器,由于某些原因设置了非常少的选项,它会自动将日期字段设置为今天的日期,当我点击外面而不选择日期时。

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?

这是我的代码:

$('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...

推荐答案

我也搜索过高低,但在发出一些调试信息之后,答案显而易见。我注意到的是onClose方法有一个value参数,它具有你选择的实际日期。如果你什么都不选,它就有你文本框中的原始值。将其设置为inputbox和walaaaa的值!问题解决了。

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.

如果你不这样做,当你只想关闭datetimepicker时,当前日期将取代原来的日期。

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

这篇关于datetimepicker在点击外部时将日期设置为今天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆