Skip to content

onChange event runs twice in Firefox #2199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stojanvujkov opened this issue May 3, 2025 · 0 comments
Open

onChange event runs twice in Firefox #2199

stojanvujkov opened this issue May 3, 2025 · 0 comments

Comments

@stojanvujkov
Copy link

stojanvujkov commented May 3, 2025

Trying to "clear" select field after an option is selected, by selecting another option right after it (with empty value in this case), results in onChange event running twice in Firefox (only). Same with selecting any option not just empty one. It works as expected in Chrome, Edge & Safari, where it runs only once. Version 0.15.2

$(document).ready(function()
{
    var $select = $('#client').selectize({
        create: false,
        sortField: 'text',
        preload: true,
        openOnFocus: true,
        valueField: 'id',
        labelField: 'text',
        allowEmptyOption: true,
        showEmptyOptionInDropdow: true,
        onChange: function(id) {
            // this runs twice in Firefox
            console.log('Selectize value changed to: ' + id);
            $select[0].selectize.setValue('', true); // select another option
        },
    });
    var selectize = $select[0].selectize;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant