I am trying to use Select2 to let users select and create tags. But creating a new tag does not work as expected as after typing two letters, the input loses focus.
This issue relates the exact same problem apparently, but mine does not get fixed with the new versions of Select2 or Jquery.
Here is the code:
- content_for :scripts do
:javascript
const input = document.querySelector('#input-tags');
$("#input-tags").select2({
tags: true,
tokenSeparators: [','],
});
= f.input :code_list, input_html: {id: 'input-tags', multiple: 'multiple'}, collection: @entry.code_list
Jquery: "jquery": "^3.5.1" Select2: "select2": "^4.0.13'
Many thanks in advance for your help!