Files
openfoodnetwork/app/webpacker/controllers/tom_select_controller.js
Jean-Baptiste Bellet 68cb8d9965 Formatting file
2022-05-24 12:30:00 +02:00

24 lines
494 B
JavaScript

import { Controller } from "stimulus";
import TomSelect from "tom-select";
export default class extends Controller {
static values = { options: Object };
static defaults = {
maxItems: 1,
maxOptions: null,
plugins: ["dropdown_input"],
allowEmptyOption: true,
};
connect() {
this.control = new TomSelect(this.element, {
...this.constructor.defaults,
...this.optionsValue,
});
}
disconnect() {
if (this.control) this.control.destroy();
}
}