Selectize.js: option for drop down to stay closed after removing item

Created on 2 Nov 2016  路  2Comments  路  Source: selectize/selectize.js

Is their an option that drop down stay closed after removing a selected item using remove_button plugin?
I set openOnFocus: false but drop down open after removing item.

question

Most helpful comment

If you populate options from an AJAX response, try this workaround:

onItemRemove: function(item) {
      // Remove the deleted item also from the set
      // of available options
      this.removeOption(item);
    },
 onItemAdd: function ( /* item */ ) {
      for(var o in this.options) {
        if(this.items.indexOf(o) === -1) {
          this.removeOption(o);
        }
      }
      this.loadedSearches = [];
      this.close();
    }

This removes all options (suggestions in the list) whenever you select or remove an item, but makes sure that the items that you remove is not selected.

All 2 comments

If you populate options from an AJAX response, try this workaround:

onItemRemove: function(item) {
      // Remove the deleted item also from the set
      // of available options
      this.removeOption(item);
    },
 onItemAdd: function ( /* item */ ) {
      for(var o in this.options) {
        if(this.items.indexOf(o) === -1) {
          this.removeOption(o);
        }
      }
      this.loadedSearches = [];
      this.close();
    }

This removes all options (suggestions in the list) whenever you select or remove an item, but makes sure that the items that you remove is not selected.

Thanks, this works fine

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Samsinite picture Samsinite  路  6Comments

tr4g picture tr4g  路  4Comments

shoaibshakeel381 picture shoaibshakeel381  路  5Comments

jaideepYes picture jaideepYes  路  5Comments

vilimco picture vilimco  路  5Comments