Events
ComboBox dispatches two events on user interaction.
- on:select Event -> Dispatched when user selects an option.
- on:clear Event -> Dispatched when user clicks on the clear icon when an option is selected.
on:select Event
// Usgage of on:select event.
<script>
import ComboBox from 'svelte-combobox/ComboBox.svelte';
const doSomething = (e) => {
// your custom code here;
// the value selected can be accessed via e.detail property;
}
</script>
<ComboBox
//props here
on:select = "{(e)=>{doSomething(e)}}"
/>
* the quotes around the function assignment (on:select="") are optional and used here for syntax highlighter.
on:clear Event
// Usgage of on:clear event.
<script>
import ComboBox from 'svelte-combobox/ComboBox.svelte';
const doSomething = (e) => {
// your custom code here;
// the value of cleared item can be accessed via e.detail property;
}
</script>
<ComboBox
// props here
on:clear="{(e)=>{doSomething(e)}}"
/>
* the quotes around the function assignment (on:clear="") are optional and used here for syntax highlighter.