0

I am trying to use select2 library with my page using php everything working perfect even is behaving well but problem is that i cannot search anything the search is by default disabled which was my main reason to use this library.

<https://jsfiddle.net/udp3qq7t/5/
kamran hassan
  • 166
  • 1
  • 1
  • 13
  • I don't know, it works for me: https://codepen.io/anon/pen/PjZKEB – Tom M Jun 09 '17 at 11:26
  • no change to me even i have used same cdn versions but after changing jquery version by your you used on codpen my modal stop functioning but still no effect to select search is disabled default – kamran hassan Jun 09 '17 at 11:44
  • could you please provide the html output of your php foreach? Also, do you have javascript errors? – Tom M Jun 09 '17 at 11:51
  • I have figure it out it is working if i use it out of modal inside modal of bootstrap it is not working no wondering there is any hack to solve it. If you can figure out please let me know . Huge thanks for help till now – kamran hassan Jun 09 '17 at 12:10

2 Answers2

0

I don't see any problem in your code. Here is the working demo of select two I extracted from your code.

<select class="scselect" name="cname">
    <option>Select</option>
    <option>Pakistan</option>
    <option>Dubai</option>
    <option>Bangladesh</option>
</select>
<script>
$(document).ready(function() {
    $(".scselect").select2({});
});
</script>

JSfiddle

Make sure PHP code is not breaking your output

Anas
  • 15
  • 4
0

I have sort out the issue by Select2 doesn't work when embedded in a bootstrap modal post.By (remove tabindex="-1" from modal)

kamran hassan
  • 166
  • 1
  • 1
  • 13