Select2 - initselection error

I get the following error when using select2 module on initSelection .

Error: Uncaught Error: No select2/compat/initSelection - the error I get.

Hope someone helps me deal with the inistselection problem.

JS:

  $(".doctor_id_pat").select2({ placeholder: "Search Users", minimumInputLength: 2, ajax: { url: "/listallergiesajax", dataType: 'json', data: function(term) { return { q: term }; }, results: function(data, page) { return { results: $.map(data, function(item) { return { text: item.text, id: item.id } }) }; }, }, initSelection: function(element, callback) { $.ajax("/listallergiesajax", { dataType: "json" }).done(function(data) { callback(data.results[0]); }); } }); 
+6
source share
1 answer

Select2 v3.5.2 uses the initSelection method. Select2 v4 has a different approach.

For information on how to update ( initSelection and other materials), see https://select2.imtqy.com/announcements-4.0.html#removed-initselection .

+21
source

Source: https://habr.com/ru/post/986136/


All Articles