SumOfUs/Champaign

View on GitHub
app/javascript/legacy/campaigner_facing/selectize_config.js

Summary

Maintainability
A
0 mins
Test Coverage
$(function() {
  $('.selectize-container').selectize({
    plugins: ['remove_button'],
    closeAfterSelect: true,
  });

  var lastVal;
  $('.selectize-container--clear-on-open').selectize({
    onDropdownOpen: function() {
      lastVal = this.getValue();
      this.clear();
    },
    onDropdownClose: function() {
      if (this.items.length < 1) this.setValue(lastVal);
    },
    closeAfterSelect: true,
  });
});