Skip to content

Commit 77953a3

Browse files
Make datepickers not share options
Calling `.datetimepicker()` on a list of elements causes them to share options, which causes issues when using data attributes to configure datetime pickers, as pickers will get the options of the datepickers before them in the document.
1 parent 5c09f6d commit 77953a3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/js/bootstrap-datetimepicker.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,11 +2402,12 @@
24022402

24032403
if (typeof options === 'object') {
24042404
return this.each(function () {
2405-
var $this = $(this);
2405+
var $this = $(this),
2406+
_options;
24062407
if (!$this.data('DateTimePicker')) {
24072408
// create a private copy of the defaults object
2408-
options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
2409-
$this.data('DateTimePicker', dateTimePicker($this, options));
2409+
_options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
2410+
$this.data('DateTimePicker', dateTimePicker($this, _options));
24102411
}
24112412
});
24122413
} else if (typeof options === 'string') {

0 commit comments

Comments
 (0)