bootstrap datetimepicker时间插件 第二次点击不显示的问题

最近在项目中引用了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
  });
},
  • 未出现双击日期控件后日期控件失效的情况。

猜你喜欢

转载自blog.csdn.net/dw5235/article/details/108049730