diff --git a/wcs/qommon/templates/qommon/forms/widgets/select-timetable.html b/wcs/qommon/templates/qommon/forms/widgets/select-timetable.html
index 8985f2360..9310eaeb7 100644
--- a/wcs/qommon/templates/qommon/forms/widgets/select-timetable.html
+++ b/wcs/qommon/templates/qommon/forms/widgets/select-timetable.html
@@ -34,17 +34,20 @@ $(function() {
$select.empty();
$('').appendTo($select);
for (var i=0; i', {value: items[i].id, text: items[i].text});
+ var date = new Date(items[i].datetime.slice(0, 10));
+ var $option = $('', {
+ value: items[i].id,
+ text: items[i].text,
+ 'data-weekday': WEEKDAYS[date.getDay()],
+ 'data-date': items[i].datetime.slice(0, 10),
+ 'data-time': items[i].datetime.slice(11, 16)
+ });
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));
- $option.attr('data-time', items[i].datetime.slice(11, 16));
$option.appendTo($select);
}
}