Set default date during picker initialization

This commit is contained in:
Christopher C. Wells 2022-07-28 20:44:42 -07:00 committed by Christopher Charbonneau Wells
parent c816726960
commit d397d169f9
7 changed files with 37 additions and 1 deletions

View File

@ -47,6 +47,18 @@ BabyBuddy.DatetimePicker = function ($, moment) {
},
viewMode: 'times',
};
// Provide the initial date value from the form, if available. This is not
// strictly necessary but acts as a workaround for a bug with certain
// locales e.g., Portuguese (pt), that causes the default value to be lost
// in the form.
// @see https://github.com/tempusdominus/bootstrap-4/issues/189#issuecomment-590791416
var id = element.attr('id');
var input = element.find(`input[data-target="#${id}"]`)
if (input.length === 1) {
defaultOptions.date = input.val()
}
element.datetimepicker($.extend(defaultOptions, options));
}
};

Binary file not shown.

View File

@ -47,6 +47,18 @@ BabyBuddy.DatetimePicker = function ($, moment) {
},
viewMode: 'times',
};
// Provide the initial date value from the form, if available. This is not
// strictly necessary but acts as a workaround for a bug with certain
// locales e.g., Portuguese (pt), that causes the default value to be lost
// in the form.
// @see https://github.com/tempusdominus/bootstrap-4/issues/189#issuecomment-590791416
var id = element.attr('id');
var input = element.find(`input[data-target="#${id}"]`)
if (input.length === 1) {
defaultOptions.date = input.val()
}
element.datetimepicker($.extend(defaultOptions, options));
}
};

BIN
static/babybuddy/js/app.926989923c57.js.gz generated Normal file

Binary file not shown.

View File

@ -47,6 +47,18 @@ BabyBuddy.DatetimePicker = function ($, moment) {
},
viewMode: 'times',
};
// Provide the initial date value from the form, if available. This is not
// strictly necessary but acts as a workaround for a bug with certain
// locales e.g., Portuguese (pt), that causes the default value to be lost
// in the form.
// @see https://github.com/tempusdominus/bootstrap-4/issues/189#issuecomment-590791416
var id = element.attr('id');
var input = element.find(`input[data-target="#${id}"]`)
if (input.length === 1) {
defaultOptions.date = input.val()
}
element.datetimepicker($.extend(defaultOptions, options));
}
};

Binary file not shown.

File diff suppressed because one or more lines are too long