fixed ie10-11 bug which prevented from selecting cell, when input had placeholder, fixes #36

This commit is contained in:
t1m0n 2016-04-13 12:21:54 +03:00
parent 6edcbcc8f8
commit 1541a90d66
4 changed files with 20 additions and 4 deletions

10
dist/js/datepicker.js vendored
View File

@ -130,6 +130,7 @@
this.keys = [];
this.minRange = '';
this.maxRange = '';
this._prevOnSelectValue = '';
this.init()
};
@ -273,6 +274,9 @@
_triggerOnChange: function () {
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);
}
@ -306,6 +310,7 @@
})
}
this._prevOnSelectValue = formattedDates;
this.opts.onSelect(formattedDates, dates, this);
},
@ -1417,7 +1422,10 @@
},
_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 () {

File diff suppressed because one or more lines are too long

View File

@ -34,7 +34,10 @@
},
_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 () {

View File

@ -130,6 +130,7 @@
this.keys = [];
this.minRange = '';
this.maxRange = '';
this._prevOnSelectValue = '';
this.init()
};
@ -273,6 +274,9 @@
_triggerOnChange: function () {
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);
}
@ -306,6 +310,7 @@
})
}
this._prevOnSelectValue = formattedDates;
this.opts.onSelect(formattedDates, dates, this);
},