Reputation: 1
On select2 4.0.2
, right after I init select2, I try to do :
$(myelement).select2("open")
and I have this error :
The select2('open') method was called on an element that is not using Select2
Upvotes: 0
Views: 1685
Reputation: 2531
Here you have a working example. Are you sure to use same element use for initialization of Select2?
$("#myField").select2();
$("#myField").select2("open");
.select2 {
width:50%
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/select2/4.0.2/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/select2/4.0.2/js/select2.full.js"></script>
<select class="form-control select2" id="myField" name="myField" autocomplete="off">
</select>
Upvotes: 1