Reputation: 37
I am developing a iOS Safari Extension and in my popup I have a checkbox. I am listening to when the box is clicked by adding event listener on the click on the input element itself. Below is a snippet of the code
popup.html
<body>
<div class="container">
<h1>Checkbox Demo</h1>
<div class="toggle-container">
<input type="checkbox" id="checkBoxID">
</div>
</div>
</body>
popup.js
document.addEventListener('DOMContentLoaded', () => {
document.querySelector('#checkBoxID').addEventListener('change', saveOptions);
});
The behavior I am seeing currently is if I click the checkbox once the saveOptions
event handler gets executed however the state of the checkbox does not change ie the check does not appear on the DOM. If I click the checkbox again the check appears but the function event handler does not run.
Upvotes: 0
Views: 6