Skip to content

How can I monitor a change to the selected value? #426

Open
@markhowellsmead

Description

@markhowellsmead

I'm using the progressive enhancement solution and I'd like to show/hide an independent element on the page when the selected value changes. If I use the onConfirm option as an event handler, then the select value is no longer passed as part of the form submission, so I guess the default function is overwritten by the custom onConfirm handler.

Is there an event I can watch using addEventListener? Using change on the select doesn't work, as the interactivity doesn't appear to apply the selected attribute to the relevant option when one of the entries is selected.

(Event listener content as follows.)

if (!!this.value) {
	authorSelect.closest('.c-articlesearchform__fieldlabel').classList.add('s-has--value');
} else {
	authorSelect.closest('.c-articlesearchform__fieldlabel').classList.remove('s-has--value');
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions