Hi @emfinanga
You're initializing select2 for all DIVs with the class js-example-basic-single on document ready, but the DIVs don't exist yet.
You need to initialize them each time you add a new row:
function addRow()
{
var div=
'<div class="form-group ">'+
'<div class="input-group">'+
'<span class="input-group-addon remove3"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></span>'+
'<select name="slave_ID[]" class="form-control js-example-basic-single" required="" data-live-search="true">'+
'<option value=" ">[SELECT SLAVE]</option>'+
'@foreach($Slave as $key=>$dt)'+
'@if($dt->devicetype ==2)'+
'<option value="{{$dt->unit_id}}">{{$dt->Devicenumber}}</option>'+
'@endif'+
'@endforeach'+
'</select>'+
'</div>'+
'</div>' ;
$('#slaveID').append(div);
$(".js-example-basic-single").select2();
};
I'd recommend adding an ID to each newly created DIV (so you can initialize only the added item, otherwise you'll be reinitializing all controls each time you add a new select).
Here's a working example: https://jsfiddle.net/174c0z5e/