Open paulodeon opened 1 year ago
I'm wrapping the https://tom-select.js.org/ library in stimulus and there are a lot of settings that I would like to set via data attributes. The problem is that this gets verbose very quickly
<%= f.select :covering_id_in, Employment.for_select, {}, { multiple: true, data: { controller: "tom-select", tom_select_color_value: "slate", tom_select_auto_submit_value: true, tom_select_placeholder_value: "Select instructor" } } %>
That's only with three values - the problem is that every value name is wrapped by controller_name_#{value_name}_value
controller_name_#{value_name}_value
A workaround is to pass an entire object which works but doesn't auto camelize the keys or provide default values
<%= f.select :covering_id_in, Employment.for_select, {}, { multiple: true, data: { controller: "tom-select", tom_select_settings_value: { color: "slate", auto_submit: true, placeholder: "Select Date Range" } } %>
Any suggestions for a better way of doing this would be appreciated!
I'm wrapping the https://tom-select.js.org/ library in stimulus and there are a lot of settings that I would like to set via data attributes. The problem is that this gets verbose very quickly
That's only with three values - the problem is that every value name is wrapped by
controller_name_#{value_name}_value
A workaround is to pass an entire object which works but doesn't auto camelize the keys or provide default values
Any suggestions for a better way of doing this would be appreciated!