简体   繁体   English

在Bootstrap模态窗口中选择在Firefox中不起作用

[英]Select in Bootstrap modal window doesn't work in Firefox

I want to make a modal window, in which i choose an option from form select and pass it for further functionallity. 我想创建一个模式窗口,在该窗口中,我从表单选择中选择一个选项,并将其传递给其他功能。 The problem is, that when the select list drops down, i can't change the selected option. 问题是,当选择列表下拉时,我无法更改选择的选项。 This problem occures only in Firefox. 仅在Firefox中会出现此问题。 In Chrome it seems working well. 在Chrome浏览器中,效果似乎不错。

Below is the code, that i used in my application. 以下是我在应用程序中使用的代码。 I don't have any additional styles or scripts, besides thoose from Bootstrap. 除了Bootstrap的选择之外,我没有任何其他样式或脚本。

 <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> Launch </button> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id="myModalLabel">Modal title</h4> </div> <div class="modal-body"> <div> <select class="form-control" > <option selected>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary" id='generate'>Generate</button> </div> </div> </div> </div> 

I removed the attribute tabindex="-1" (or sets to 0) of the modal, and I added javascript: 我删除了模态的属性tabindex="-1" (或设置为0),并添加了javascript:

$.fn.modal.Constructor.prototype.enforceFocus = $.noop;
https://github.com/select2/select2/issues/4091#issuecomment-172633858 -> https://github.com/select2/select2/issues/4091#issuecomment-172633858->

Solution : https://github.com/select2/select2/issues/600#issuecomment-102857595 解决方案https : //github.com/select2/select2/issues/600#issuecomment-102857595

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM