在 Bootstrap 模式窗口中选择在 Firefox 中不起作用 [英] Select in Bootstrap modal window doesn't work in Firefox

查看:17
本文介绍了在 Bootstrap 模式窗口中选择在 Firefox 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个模态窗口,在其中我从表单选择中选择一个选项并将其传递给进一步的功能.The problem is, that when the select list drops down, i can't change the selected option.此问题仅在 Firefox 中出现.在 Chrome 中它似乎运行良好.

以下是我在应用程序中使用的代码.除了来自 Bootstrap 的那些之外,我没有任何其他样式或脚本.

<div class="modal-body"><div><select class="form-control" ><选择的选项>1</option><option>2</option><选项>3</选项><选项>4</选项><option>5</option></选择>

<div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">关闭</button><button type="button" class="btn btn-primary" id='generate'>Generate</button>

解决方案

我删除了模态的属性 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/600#issuecomment-102857595

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. In Chrome it seems working well.

Below is the code, that i used in my application. I don't have any additional styles or scripts, besides thoose from 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:

$.fn.modal.Constructor.prototype.enforceFocus = $.noop;

https://github.com/select2/select2/issues/4091#issuecomment-172633858 ->

Solution: https://github.com/select2/select2/issues/600#issuecomment-102857595

这篇关于在 Bootstrap 模式窗口中选择在 Firefox 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆