fix option list not updating properly
This commit is contained in:
parent
d2a2d9459a
commit
1e88a4bdcf
1 changed files with 14 additions and 12 deletions
|
@ -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);
|
||||||
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
document.querySelectorAll('#theme-select>option').forEach(element => {
|
document.querySelectorAll('#theme-select>option').forEach(element => {
|
||||||
if (element.value === theme) {
|
if (element.value === theme) {
|
||||||
element.selected = 'selected';
|
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);
|
|
||||||
}
|
|
||||||
});
|
|
Loading…
Add table
Reference in a new issue