mirror of
https://github.com/frappe/air-datepicker.git
synced 2026-01-14 11:01:22 +08:00
fixed ie10-11 bug which prevented from selecting cell, when input had placeholder, fixes #36
This commit is contained in:
parent
6edcbcc8f8
commit
1541a90d66
10
dist/js/datepicker.js
vendored
10
dist/js/datepicker.js
vendored
@ -130,6 +130,7 @@
|
|||||||
this.keys = [];
|
this.keys = [];
|
||||||
this.minRange = '';
|
this.minRange = '';
|
||||||
this.maxRange = '';
|
this.maxRange = '';
|
||||||
|
this._prevOnSelectValue = '';
|
||||||
|
|
||||||
this.init()
|
this.init()
|
||||||
};
|
};
|
||||||
@ -273,6 +274,9 @@
|
|||||||
|
|
||||||
_triggerOnChange: function () {
|
_triggerOnChange: function () {
|
||||||
if (!this.selectedDates.length) {
|
if (!this.selectedDates.length) {
|
||||||
|
// Prevent from triggering multiple onSelect callback with same argument (empty string) in IE10-11
|
||||||
|
if (this._prevOnSelectValue === '') return;
|
||||||
|
this._prevOnSelectValue = '';
|
||||||
return this.opts.onSelect('', '', this);
|
return this.opts.onSelect('', '', this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +310,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._prevOnSelectValue = formattedDates;
|
||||||
this.opts.onSelect(formattedDates, dates, this);
|
this.opts.onSelect(formattedDates, dates, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1417,7 +1422,10 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_bindEvents: function () {
|
_bindEvents: function () {
|
||||||
this.$el.on('click', '.datepicker--cell', $.proxy(this._onClickCell, this));
|
// Use 'mouseup' and 'click' events instead of 'click' because of IE 10-11 bug, which triggers 'input' event
|
||||||
|
// when placeholder value is changed (e.g. when user just focus input). It causes calling clear() method,
|
||||||
|
// which clears input value and prevents from selecting cell. (issue #36)
|
||||||
|
this.$el.on('click mouseup', '.datepicker--cell', $.proxy(this._onClickCell, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildBaseHtml: function () {
|
_buildBaseHtml: function () {
|
||||||
|
|||||||
4
dist/js/datepicker.min.js
vendored
4
dist/js/datepicker.min.js
vendored
File diff suppressed because one or more lines are too long
@ -34,7 +34,10 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_bindEvents: function () {
|
_bindEvents: function () {
|
||||||
this.$el.on('click', '.datepicker--cell', $.proxy(this._onClickCell, this));
|
// Use 'mouseup' and 'click' events instead of 'click' because of IE 10-11 bug, which triggers 'input' event
|
||||||
|
// when placeholder value is changed (e.g. when user just focus input). It causes calling clear() method,
|
||||||
|
// which clears input value and prevents from selecting cell. (issue #36)
|
||||||
|
this.$el.on('click mouseup', '.datepicker--cell', $.proxy(this._onClickCell, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildBaseHtml: function () {
|
_buildBaseHtml: function () {
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
this.keys = [];
|
this.keys = [];
|
||||||
this.minRange = '';
|
this.minRange = '';
|
||||||
this.maxRange = '';
|
this.maxRange = '';
|
||||||
|
this._prevOnSelectValue = '';
|
||||||
|
|
||||||
this.init()
|
this.init()
|
||||||
};
|
};
|
||||||
@ -273,6 +274,9 @@
|
|||||||
|
|
||||||
_triggerOnChange: function () {
|
_triggerOnChange: function () {
|
||||||
if (!this.selectedDates.length) {
|
if (!this.selectedDates.length) {
|
||||||
|
// Prevent from triggering multiple onSelect callback with same argument (empty string) in IE10-11
|
||||||
|
if (this._prevOnSelectValue === '') return;
|
||||||
|
this._prevOnSelectValue = '';
|
||||||
return this.opts.onSelect('', '', this);
|
return this.opts.onSelect('', '', this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +310,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._prevOnSelectValue = formattedDates;
|
||||||
this.opts.onSelect(formattedDates, dates, this);
|
this.opts.onSelect(formattedDates, dates, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user