Skip to content

optionUpdated

optionUpdated is a DOM event that occurs whenever the option of the h-select webcomponent gets updated.

Event body

The optionUpdated body has a string type which represents the value of a previously selected option. It is optional so it might not exist. The object contains the following fields:

Field name Type Description
$option HOption Option that just got updated

Example

In this example we listen to optionUpdated event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    document.addEventListener('optionUpdated', (event) => {
        const $option = event.detail.$option;

        console.log($option, ' got updated');
    });
});