Any Suggestions For Disabling A Select2 Option?

Any Suggestions For Disabling A Select2 Option?

customstockalertscustomstockalerts Posts: 6Questions: 2Answers: 0

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

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    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.

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Answer ✓

    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

  • customstockalertscustomstockalerts Posts: 6Questions: 2Answers: 0

    Awesome I appreciate the quick turnaround, it felt like I couldn't be alone in said issue.

  • customstockalertscustomstockalerts Posts: 6Questions: 2Answers: 0

    Hey Allan had you gotten around to this yet? Thanks

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Not yet sorry. Had hoped to do it yesterday, but ran out of time. I'll try to make some later on.

    Allan

This discussion has been closed.