最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Select2 default search box not working - Stack Overflow

programmeradmin5浏览0评论

I am using select2 js I am just using default function, but the default search box is showing in disabled mode. i am not able to type anything in it.

My code is

<select id="type" name="type" class="form-control select2-use">
    <option value="">select type</option>
    <option value="U">User</option>
    <option value="A">Admin</option>
</select>

$('.select2-use').select2({
    placeholder: "Select",
    allowClear: true
});

I have included the select2.min.css and select2.min.js in my HTML page.

There is no js errors.

I am using this in Bootstrap modal div in which i load a HTML page

I am using select2 js I am just using default function, but the default search box is showing in disabled mode. i am not able to type anything in it.

My code is

<select id="type" name="type" class="form-control select2-use">
    <option value="">select type</option>
    <option value="U">User</option>
    <option value="A">Admin</option>
</select>

$('.select2-use').select2({
    placeholder: "Select",
    allowClear: true
});

I have included the select2.min.css and select2.min.js in my HTML page.

There is no js errors.

I am using this in Bootstrap modal div in which i load a HTML page

Share Improve this question edited Jun 22, 2016 at 13:37 Sunil Pachlangia asked Jun 22, 2016 at 13:19 Sunil PachlangiaSunil Pachlangia 2,0613 gold badges17 silver badges26 bronze badges 7
  • 1 Can you replicate it in snippet or fiddle? – Guruprasad J Rao Commented Jun 22, 2016 at 13:20
  • To me works fine, look at this: jsfiddle/40eemy84/9 – Teuta Koraqi Commented Jun 22, 2016 at 13:27
  • @TeutaKoraqi Works for me as well except searchbox – Sunil Pachlangia Commented Jun 22, 2016 at 13:29
  • Can you provide a fiddle? – Teuta Koraqi Commented Jun 22, 2016 at 13:30
  • @TeutaKoraqi I am using this in Bootstrap modal div in which i load a HTML page – Sunil Pachlangia Commented Jun 22, 2016 at 13:36
 |  Show 2 more ments

1 Answer 1

Reset to default 16

Your code looks ok: https://jsfiddle/3tfjn9zb/1/

Are you using it in a bootstrap modal? If so: try to remove tabindex="-1" from the modal div.

发布评论

评论列表(0)

  1. 暂无评论