When placing select2 inside the jQuery dataTable, the select2 is not working, when I move it outside the table that is managed by dataTable it works. Here is a example code that shows the issue, in this example same table row is repeated 12 times, and for some odd reason the row number 10 shows up as a select2 managed row but not the others. The issue is validated in latest Chrome and Edge in windows 10 fully updated as of 2019-06-22
Thanks
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<title>T1</title>
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- font awesome stuff -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<script src="js/jquery.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway:400,800">
<link rel='stylesheet' href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/bootstrap.css">
<!-- select2 -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
<!-- used for sorting -->
<link rel="stylesheet" href="http://cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css">
<script type="text/javascript" src="http://cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script>
<script>
// jQuery to build a sortable table, use table ID to link it up
$(document).ready(function() {
$('#TestTable').dataTable();
});
</script>
<script>
jQuery(document).ready( function () {
/* this makes the select/option element be customizable. using select2 */
jQuery(".experience-jquerySelect2-tag").select2( { tags: true } );
});
</script>
<!-- End -->
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
</head>
<body>
<div class="container">
<div class="row">
<!-- for a small display fill 12 columns same for mid size display-->
<div class="col-sm-12 col-md-12">
<!-- for this car use mb-2 which means the margin or padding to $spacer * .5-->
<div class="card mb-2">
<!-- for px-1 and py-1 the x - for classes that set both *-left and *-right and
the y - for classes that set both *-top and *-bottom -->
<div class="card-body text-left px-1 py-1">
<div class="card-text">Test</div>
<small class="text-muted">hint hint</small>
<div class="p-1 mb-0 bg-warning" style="height: 10px;"> </div>
<div style="overflow-x:auto;">
<!-- table-sm for compact table, table-striped for odd,even coloring -->
<table class="table-sm table-striped table-condensed" id="TestTable">
<thead>
<tr class="small">
<th scope="col">Drop Down</th>
</tr>
</thead>
<tbody>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="small text-nowrap">
<span class="form-group">
<select class="form-control experience-jquerySelect2-tag" id="IDexperience" name="experience" required>
<option value="Test1">Test 1</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>