Is it possible to make this working for dynamically (using Jquery and not ajax ) elements?
Basically, using JQuery I would add a new row with a select element and want to bind that new element with the select2.
It was not difficult to make it work:
/*Bind select to the newly created country selectbox*/
$("#country"+next).select2({
placeholder: "Select a country",
allowClear: true,
data: data
});
setTimeout(function(){
$('.select2').select2();
}, 100);
use this when adding new row
Check if when you copy the new country select element you keep the element id. If so you must delete the id
Most helpful comment
setTimeout(function(){
$('.select2').select2();
}, 100);
use this when adding new row