Replies: 1 comment 1 reply
-
I'm not sure exactly what you're asking. You can programmatically alter the checkbox's <sl-checkbox>Checkbox</sl-checkbox>
<br><br>
<sl-button>Toggle without event</sl-button>
<script>
const checkbox = document.querySelector('sl-checkbox');
const button = document.querySelector('sl-button');
// Only logs when toggling the checkbox (not the button)
checkbox.addEventListener('sl-input', () => console.log('checked'));
button.addEventListener('click', () => {
checkbox.checked = !checkbox.checked;
});
</script> If you're trying to stop checkbox.addEventListener('sl-input', event => {
event. stopImmediatePropagation();
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone, I have a problem with the sl-change event on sl-checkbox component, I needed to change it without checked status, is it possible?
I saw in the sl-checkbox code and his handleClick event has
this.checked = !this.checked;
is it possible to overwrite all the lines and only emit my own event?
I tried to change it on my sl-change event, however it is not working 🫤, could someone has any previous experience on it or has a comment?
Thank you☺️
Beta Was this translation helpful? Give feedback.
All reactions