ugly kludge to honor default selection in dropdown...
This commit is contained in:
parent
be9e210112
commit
784a315d85
23
script.js
23
script.js
@ -117,18 +117,9 @@ const topicSelect = document.querySelector('#topic-select');
|
|||||||
const topicChanged = function () {
|
const topicChanged = function () {
|
||||||
console.log('topic changed');
|
console.log('topic changed');
|
||||||
topic = topicSelect.selectedOptions[0].id;
|
topic = topicSelect.selectedOptions[0].id;
|
||||||
|
|
||||||
redrawTable();
|
redrawTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
topicSelect.addEventListener("change", topicChanged);
|
|
||||||
|
|
||||||
for (let x in topics) {
|
|
||||||
let option = document.createElement('option');
|
|
||||||
option.id = x;
|
|
||||||
option.text = topics[x].title;
|
|
||||||
topicSelect.add(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the seed from URL Parameter or generates new seed
|
* Reads the seed from URL Parameter or generates new seed
|
||||||
@ -146,6 +137,20 @@ if (urlParams.has('topic')) {
|
|||||||
topic = 'tinder';
|
topic = 'tinder';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let index = 0;
|
||||||
|
for (let x in topics) {
|
||||||
|
let option = document.createElement('option');
|
||||||
|
option.id = x;
|
||||||
|
option.text = topics[x].title;
|
||||||
|
topicSelect.add(option);
|
||||||
|
if (x === topic) {
|
||||||
|
topicSelect.selectedIndex = index;
|
||||||
|
};
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
topicSelect.addEventListener("change", topicChanged);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set fields, headline and center image based on topic
|
* Set fields, headline and center image based on topic
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user