Choices-js / Choices

A vanilla JS customisable select box/text input plugin ⚡️
https://choices-js.github.io/Choices/
MIT License
6.06k stars 597 forks source link

Auto submitting form after choice needs timeout? #1064

Open stell opened 1 year ago

stell commented 1 year ago

So to make it simple:

const myselect = new Choices('#myselect', mySelectInit);
myselect.passedElement.element.addEventListener(
    'choice',
    (e) => {
        setTimeout(function () {
            document.getElementById('myForm').requestSubmit();
        }, 10);
    },
    false,
);

When not using the timeout, the new chosen value is not getting submitted.

Am I missing something?