Select2 issues : v4 not working with jsoneditor, and enumSource not working with uniqueItems array
See original GitHub issueHi there,
First of all, thanks a lot for your work, jsoneditor is amazing !
I’ll drop here some issues I’ve found with select2, and that matches other previous issues i’ve found on github. This post is just for issue report purposes, in case anyone else is looking for an answer, and eventually to merge all the select2 issues. Feel free to close or merge this post if needed.
1) Select2 v4 not working properly with jsoneditor
I was at first using select2 v4.0.2 and jsoneditor wasn’t getting any value. Searching the repo for similar issues, i’ve found this post that refer to it : issues/231
Temporary fix : use previous version of select2. For me, v3.5.4 worked well.
2) “array” type with uniqueItems not working with enumSource
I’ve also found a related issue here on the repo, althought it’s a closed issue : issue/225
Here is my code, just in case. “products” is a another array type with object items. I’m using mustache template.
"choice_excluded": {
"type": "array",
"uniqueItems":true,
"format":"select",
"items": {
"type":"string",
"watch": { "excluded_products": "products" },
"enumSource": [{
"source": "excluded_products",
"title": "{{item.name_product}}",
"value": "{{item.slug_product}}"
}]
}
}
Am I doing something wrong ?
I haven’t found a satisfying solution for now, so i’m just using an empty array, and I need to add each item manually.
Thanks in advance !
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:6
Top GitHub Comments
I am also having issues with select2 v4 when using the “startval” option or the “setValue” method. I disabled it by overriding the prototype method “setupSelect2” by adding this line before initializing the editor:
JSONEditor.defaults.editors.select.prototype.setupSelect2 = function() { this.select2 = null; }
select2 v4 does not update values because the listner for multiselect only listen to ‘select2-blur’ event. This event has not been implemented (yet) in v4. in select editor someone have added support for ‘change’ event, but this has not been added in the multiselect editor.
Under setupSelect2 for JSONEditor.defaults.editors.multiselect I added:
below the existing section for ‘select2-blur’.
Now value is updated on changes in select2 multiselect.
HTH (very new to github, so don’t know how to submit this)