Closed salcode closed 7 years ago
I've modified the select2 initialization for pw_select2
to support data attributes for templates (templateResult
and templateSelection
). Without my modifications, template names for data attributes don't work as data attributes because they are functions (rather than string values).
My work is in branch sf/template-41 of my fork of this project. I'm not sure if this is worth considering merging into this project. It may be better to create a PR for Select2. Nevertheless, I wanted to document this here in case someone else has the same need ( or if I need to do it again in the future and forget how 😀 )
Thank you for taking the time to not only raise this but also for offering a solution.
I’ll regret this when I personally find a use case for it... I’m going to take the possibly lazy view that this is more elegantly addressed upstream with Select2. In an ideal world it’d be possible to specify this configuration via a data attribute.
Thanks again.
First, let me say thank you for this project and sharing it publicly - it has been a big help.
The stumbling block I've hit is I'm trying to use a custom Select2 template.
Unfortunately, defining templates via data attribute is not supported in Select2. There is a work-around in the issue written in CoffeeScript but I've not yet looked into it.