Select2 field type - update() method - how to 'append' new options?
Select2 field type - update() method - how to 'append' new options?
Hi- as per the select field type documentation, the update() method has an optional 'append' parameter to specify that the provided options should be added to the existing list of options, rather than replacing them. I'm trying to achieve the same effect with a Select2 field type.
I explored a solution using the inst() method to get the underlying Select2 object, and then using the native Select2 'append' method, but this resulted in duplicate options appearing the next time the Select2 is opened (I'm using the inline editing mode, in case that's relevant.) Any guidance appreciated- thanks in advance!
Answers
Could you link to the page, or create a test case, that shows the duplication, please. It'll help us to understand what you'retrying to do,
Colin
Thanks for the reply, but I was able to adapt the existing update() function in the Select2 plugin to add an 'append' parameter mirroring that available for the normal select field type. Probably not the most elegant implementation, but it works! Code below in case this is of help to others.