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);
|
||||
if (theme) {
|
||||
changeTheme(theme);
|
||||
document.querySelectorAll('#theme-select>option').forEach(element => {
|
||||
if (element.value === theme) {
|
||||
element.selected = 'selected';
|
||||
}
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
document.querySelectorAll('#theme-select>option').forEach(element => {
|
||||
if (element.value === theme) {
|
||||
element.selected = 'selected';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
document.getElementById('theme-select').onchange = function () {
|
||||
changeTheme(this.value);
|
||||
}
|
||||
});
|
||||
|
||||
function changeTheme(themeName) {
|
||||
let alternates = [];
|
||||
|
||||
|
@ -34,9 +42,3 @@ function changeTheme(themeName) {
|
|||
function saveTheme(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