Select2 jquery does not allow adding new tags

I have this code and I can’t add new tags, just selects those from ajax.

<script> $(document).ready(function() { $.ajax({ url: "ajax/profile.php", type: "POST", dataType: "json", success: function(data) { //alert(data); $("#PROFILE").select2({ tags: data, tokenSeparators: [","] }); }, error: function(jqXHR, textStatus, errorThrown) { alert("Ocurrio un error al enviar los datos"); } }); }); </script> 

appreciate your help

+4
source share
1 answer

Add the code below inside the select2() function. Check out this script

 createSearchChoice: function (term) { return { id: term, text: term }; } 
+10
source

All Articles