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