fix option list not updating properly

This commit is contained in:
Worble 2019-05-06 23:18:32 +01:00
parent d2a2d9459a
commit 1e88a4bdcf

View file

@ -3,13 +3,21 @@ const THEME_KEY = "ZULMA_THEME";
let theme = localStorage.getItem(THEME_KEY); let theme = localStorage.getItem(THEME_KEY);
if (theme) { if (theme) {
changeTheme(theme); changeTheme(theme);
document.querySelectorAll('#theme-select>option').forEach(element => { window.addEventListener('DOMContentLoaded', () => {
if (element.value === theme) { document.querySelectorAll('#theme-select>option').forEach(element => {
element.selected = 'selected'; if (element.value === theme) {
} element.selected = 'selected';
}
});
}); });
} }
window.addEventListener('DOMContentLoaded', () => {
document.getElementById('theme-select').onchange = function () {
changeTheme(this.value);
}
});
function changeTheme(themeName) { function changeTheme(themeName) {
let alternates = []; let alternates = [];
@ -34,9 +42,3 @@ function changeTheme(themeName) {
function saveTheme(themeName) { function saveTheme(themeName) {
localStorage.setItem(THEME_KEY, themeName); localStorage.setItem(THEME_KEY, themeName);
} }
window.addEventListener('load', () => {
document.getElementById('theme-select').onchange = function () {
changeTheme(this.value);
}
});