Selectize.js: closeAfterSelect not working

Created on 24 Oct 2015  路  4Comments  路  Source: selectize/selectize.js

closeAfterSelect is not working with create: true.

$('#select-gear').selectize({
plugins: ['remove_button'],
create: true,
closeAfterSelect: true
});

Most helpful comment

What's actually being observed is how the remove_button plugin works in the selectize demo. After deleting an item (removing), selectize pops back open.

This didn't make any sense to us either, so the (hackish) solution we came up with (shout out to @marcamos) was to trap item_remove, set the opacity to 0 immediately, then use a setTimeout to bring the opacity back after all selectize events were done firing:

selectize.on("item_remove", function()  {
    $(".selectize-dropdown").css("opacity", "0");

    setTimeout(function() {
        selectize.close();
        selectize.blur();
        $(".selectize-dropdown").css("opacity", "1");
    }, 100);
});

There are other ways to do this, using the onDelete callback, etc. Anyway, sharing in case it helps someone else!

All 4 comments

+1

+1

What's actually being observed is how the remove_button plugin works in the selectize demo. After deleting an item (removing), selectize pops back open.

This didn't make any sense to us either, so the (hackish) solution we came up with (shout out to @marcamos) was to trap item_remove, set the opacity to 0 immediately, then use a setTimeout to bring the opacity back after all selectize events were done firing:

selectize.on("item_remove", function()  {
    $(".selectize-dropdown").css("opacity", "0");

    setTimeout(function() {
        selectize.close();
        selectize.blur();
        $(".selectize-dropdown").css("opacity", "1");
    }, 100);
});

There are other ways to do this, using the onDelete callback, etc. Anyway, sharing in case it helps someone else!

closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.

Was this page helpful?
0 / 5 - 0 ratings