select2 jquery not allow to add new tags
Asked Answered
C

1

4

I have this code and I do not allow to add new tags just picks those from the 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

Calendra answered 10/9, 2013 at 14:51 Comment(0)
J
10

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

createSearchChoice: function (term) {
  return { id: term, text: term };
}
Jennings answered 16/10, 2013 at 6:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.