I used Select2 4.0.6, I have a bug like below:
allowClear gives "Uncaught TypeError: Cannot read property 'id' of undefined" when used on select.
How can I fix this bug?.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<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>
</head>
<body>
<select role="select" id="myoption">
<option value="001">abcs </option><option value="002">dshdsh</option><option value="003">A</option>
<option value="004">ANAM CO</option>
</select>
</body>
</html>
<script>
$("#myoption").select2({
allowClear: true,
width: '300px',
height: '34px'
//data: data
});
</script>
x
in the select and you'll see the error. – Eggert