From 9bce2ca64cc0885b21d259882ac84db01263e9d9 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 29 Jan 2022 18:19:55 +0000 Subject: [PATCH] Allow initializing with custom TomSelect configurations --- app/webpacker/controllers/tom_select_controller.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/webpacker/controllers/tom_select_controller.js b/app/webpacker/controllers/tom_select_controller.js index 93f10a50d3..e1b7a65dfb 100644 --- a/app/webpacker/controllers/tom_select_controller.js +++ b/app/webpacker/controllers/tom_select_controller.js @@ -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() {