widgets: keep track of selected value in dynamic timetables (#51841)

This commit is contained in:
Frédéric Péters 2021-03-09 14:58:34 +01:00
parent 54e43a6728
commit 08780d7935
2 changed files with 4 additions and 0 deletions

View File

@ -351,6 +351,7 @@ $(function() {
var $option = $('<option></option>', {value: value.items[i].id, text: value.items[i].text});
if (value.items[i].id == current_value) {
$option.attr('selected', 'selected');
value.items[i].selected = true;
}
$option.appendTo($select);
}

View File

@ -38,6 +38,9 @@ $(function() {
if (items[i].disabled) {
$option.prop('disabled', true);
}
if (items[i].selected) {
$option.attr('selected', true);
}
var date = new Date(items[i].datetime);
$option.attr('data-weekday', WEEKDAYS[date.getDay()]);
$option.attr('data-date', items[i].datetime.slice(0, 10));