I am working on a case that there are two modals. each modal contains a select2 search dropdown. The issue I am facing is whenever I select modal one, the data for the dropdown is filtered, works perfect. then when I select modal two, the data are filtered on console once the event is triggered but not on the dropdown. it says "No Results Found".
If i repeat the tasks as in, selecting modal two first: the data are filtered, no issue. after when modal one is chosen, the search dropdown is no where to be seen. After some testings what I understood is the JS files are conflicting with each other.
modal one JS
<!-- Internal Sumoselect js -->
<script src="assets/plugins/sumoselect/jquery.sumoselect.js"></script>
<!-- Internal Select2 js -->
<!-- <script src="assets/js/select2.js"></script> -->
<script src="../assets/plugins/select2/js/select2.min.js"></script>
<!-- Internal Form-elements js -->
<script src="assets/js/advanced-form-elements.js"></script>
<!-- Internal Modal js-->
<script src="assets/js/modal.js"></script>
modal two JS
<!-- Internal Sumoselect js -->
<script src="assets/plugins/sumoselect/jquery.sumoselect.js"></script>
<!-- Internal Form-elements js -->
<script src="assets/js/advanced-form-elements.js"></script>
<!-- Internal Select2 js -->
<!-- <script src="assets/js/select2.js"></script> -->
<script src="assets/plugins/select2/js/select2.min.js"></script>
<!--Internal Datepicker js -->
<script src="assets/plugins/jquery-ui/ui/widgets/datepicker.js"></script>
<!--Internal jquery-simple-datetimepicker js -->
<script src="assets/plugins/amazeui-datetimepicker/js/amazeui.datetimepicker.min.js"></script>
<!-- Ionicons js -->
<script src="assets/plugins/jquery-simple-datetimepicker/jquery.simple-dtpicker.js"></script>
<!--Internal pickerjs js -->
<script src="assets/plugins/pickerjs/picker.min.js"></script>
<!-- Internal Modal js-->
<script src="assets/js/modal.js"></script>
Where the conflicts could possibly happen?
The solution was silly. The select2 dropdowns from both modals ID were same. simply the basic is ID should be unique.