Any Suggestions For Disabling A Select2 Option?
Any Suggestions For Disabling A Select2 Option?
Hey there, I'm using the select2 integration for my site and I'm looking to expand some functionality. I'd like to be able to disable an individual option programmatically.
https://editor.datatables.net/plug-ins/field-type/editor.select2
https://select2.github.io/examples.html#disabled-results
DataTables doesn't seem to pass any parameter other than the ID and value, I had tried adding a "disabled" option to the array that DT reads from.
Is there a clean way to access and add the property to the option of the select2 field?
This question has an accepted answers - jump to answer
Answers
No. I spent a fair amount of time trying to solve this issue. I had some working code (wish I remembered where I put it), but I think it is actually easier to destroy, set the disabled option and then rebuild the select2.
I think this is something that should be added to the integration plug-in. The built in
select
(and a few others) field has the ability to set attributes specifically for each input. It makes sense that this ability should be available for the plugin as well.I'll post back when its done.
Allan
Awesome I appreciate the quick turnaround, it felt like I couldn't be alone in said issue.
Hey Allan had you gotten around to this yet? Thanks
Not yet sorry. Had hoped to do it yesterday, but ran out of time. I'll try to make some later on.
Allan