Skip to content

onChange event runs twice in Firefox #2199

Open
@stojanvujkov

Description

@stojanvujkov

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;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions