Allow initializing with custom TomSelect configurations

This commit is contained in:
Matt-Yorkley
2022-01-29 18:19:55 +00:00
parent fedfeb6dd3
commit 9bce2ca64c

View File

@@ -2,15 +2,18 @@ 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,
allowEmptyOption: true
}
connect() {
this.control = new TomSelect(this.element, this.constructor.defaults)
this.control = new TomSelect(
this.element, { ...this.constructor.defaults, ...this.optionsValue }
)
}
disconnect() {