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

最近在项目中引用了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

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值