select2 createTag issue with editor
select2 createTag issue with editor
Trying to get select2 createTag to work per https://select2.org/tagging. I get error at dataTables.editor.js line 5275 because canReturnSubmit not defined for the field.
found https://datatables.net/forums/discussion/comment/140478/#Comment_140478, but not sure the correct setting. In any case the select2 fieldtype plugin should be updated if canReturnSubmit is required
Else dataTables.editor.js should verify function exists before calling it
See https://codepen.io/louking/pen/LMGVJm, and enter some new option into the select search box for col0
This question has an accepted answers - jump to answer
Answers
actually this issue occurs with or without createTag, so the subject is a bit misleading
Found a couple issues:
select2.js
twice with two different versions. Probably should only load it onceeditor.select2.js
plugin before loadingdataTables.editor.js
I reversed the load order for 2 and commented out the second
select2.js
in 1, you will see the comments:https://codepen.io/anon/pen/MZKoMB?editors=1010#0
The example seems to work now.
Kevin
Thanks for looking at this and fixing some typos, but your version still has the problem.
I think either https://editor.datatables.net/plug-ins/field-type/editor.select2 (and other plugins?) should be extension of
baseFieldType
defined at dataTables.editor.js 8985, or line 5275 should be similar to line 5289.Probably also https://editor.datatables.net/manual/development/field-types should be updated to be extension of baseFieldType if that's the correct solution.
I tried again but don't see that error. How do your recreate in the updated example?
Kevin
bring up console, click New, click on the select2 control, type 'test' in the search box, hit carriage return
I use chrome development tools which default to stop on exception. console should show the error in any case.
Right, hitting return makes sense. I was clicking out of the cell
I'm not sure what the issue is. I have a select2 field configured similarly with tags but don't have the issue. However I am using an old version of Editor (1.6.2) on that page.
Maybe @allan or @colin can find something.
Kevin
100% agree - this is an error in Editor I'm afraid. There is a
keydown
event handler which callscanReturnSubmit
- that is where the error is coming from and it should check for the function. If you find:and replace it with:
That will do it.
Regards,
Allan
Sorry - I forgot to add, Kevin won't see this in 1.6.x since the key handling was modified since then.
Allan