bootstrap-datatimepicker双击失效问题解决。

来源:互联网 发布:闲鱼拒绝退款 淘宝介入 编辑:程序博客网 时间:2024/06/11 00:27

最近在项目中引用了bootstrap-datatimepicker控件,但是发现该控件在日期选择框弹出状态下再次点击input则日期选择框消失但再次点击input日期选择框不再弹出。

解决办法:

在日期控件的show方法中给input加上disabled属性。在hide方法中取消disabled属性。

show: function (e) {  this.picker.show();  this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();  if (this.forceParse) {    this.update();  }  this.element[0].disabled = true;  this.place();  $(window).on('resize', $.proxy(this.place, this));  if (e) {    e.stopPropagation();    e.preventDefault();  }  this.isVisible = true;  this.element.trigger({    type: 'show',    date: this.date  });},hide: function (e) {  if (!this.isVisible) return;  if (this.isInline) return;  this.picker.hide();  $(window).off('resize', this.place);  this.viewMode = this.startViewMode;  this.showMode();  if (!this.isInput) {    $(document).off('mousedown', this.hide);  }  this.element[0].disabled = false;  if (    this.forceParse &&      (        this.isInput && this.element.val() ||          this.hasInput && this.element.find('input').val()        )    )    this.setValue();  this.isVisible = false;  this.element.trigger({    type: 'hide',    date: this.date  });},

经测试未出现双击日期控件后日期控件失效的情况。

js下载链接:bootstrap-timepicker.js

0 0
原创粉丝点击