I have a problem with select2 jquery. I want to fix the option to a particular option when it populates data from the database. But I don't want to use the change because there are other events tied to it. Is there any possibility to fix an option in select2 without triggering the change?
The current code is like this. But I don't want to trigger the change.
$('.roles').val(v).attr("old", v).attr('rowid', dc.id).trigger("change.select2");
I solved the issue. I had to reinitialize the select box after setting the value like the following
$('.roles').val(3);
$(".roles").select2({
minimumResultsForSearch: -1,
})