js: Only show a single datetime picker in each container at a time
This commit is contained in:
parent
b75cf362b8
commit
23ee95e45f
|
@ -87,6 +87,9 @@
|
|||
return format === this.dateFormat
|
||||
? Flatpickr.formatDate(date, format, locale)
|
||||
: dateTimeFormatter.format(date);
|
||||
},
|
||||
onOpen: function (selectedDates, dateStr, instance) {
|
||||
_this.closePickers(instance);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -135,6 +138,20 @@
|
|||
}, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Close all other flatpickr instances and keep the given one
|
||||
*
|
||||
* @param fp {Flatpickr}
|
||||
*/
|
||||
DatetimePicker.prototype.closePickers = function (fp) {
|
||||
var containerId = this._pickers.get(fp);
|
||||
this._pickers.forEach(function (cId, fp2) {
|
||||
if (cId === containerId && fp2 !== fp) {
|
||||
fp2.close();
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
DatetimePicker.prototype.createFormatter = function (withDate, withTime) {
|
||||
var options = {};
|
||||
if (withDate) {
|
||||
|
|
Loading…
Reference in New Issue