Bootstrap模式不适用于iPhone

时间:2018-03-21 14:55:35

标签: javascript jquery html iphone

这是模式:

<div class="modal fade" id="modalInsertAgression" tabindex="-1" role="dialog" aria-labelledby="modalInsertAgression" aria-hidden="true">
<div class="modal-dialog" role="document">
    <div class="card">

        <form id="formInsertarAgresion" action="{% url 'insertarAgresion' %}" role="form">{% csrf_token %}
            <div class="card-header card-header-icon" data-background-color="rose">
                <i class="material-icons">place</i>
            </div>

            <div class="card-content">
                <h4 class="card-title">Test</h4>
                <p class="text-center" id="msgModalInsertAgression"></p>
                <br>

                <div class="input-group">
                    <span class="input-group-addon"><i class="material-icons">date_range</i></span>
                    <div class="form-group">{{ agresionForm.fecha }}</div>
                </div>
            </div>

            <div class="card-footer pull-right">
                <button id="btnInsertModalInsertAgression" type="submit" class="btn btn-fill btn-rose">Insertar</button>
                <button id="btnCloseModalInsertAgression" type="button" class="btn btn-default btn-fill" data-dismiss="modal">Cancelar</button>
            </div>
        </form>

    </div>
</div>

我打开它:

$("#modalInsertAgression").show();

它在iPhone上不起作用,当模态出现时背景保持黑色并失去焦点,你无法点击模态或按钮。

编辑:该模式仅适用于$("#modalInsertAgression").modal({backdrop: false});,但我不想失去黑色背景......

2 个答案:

答案 0 :(得分:0)

尝试(在 iOS 11上测试):

$('#modalInsertAgression').modal('show');

段:

&#13;
&#13;
$('#modalInsertAgression').modal('show');
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="modal fade" id="modalInsertAgression" tabindex="-1" role="dialog" aria-labelledby="modalInsertAgression" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="card">
      <form id="formInsertarAgresion" action="{% url 'insertarAgresion' %}" role="form">{% csrf_token %}
        <div class="card-header card-header-icon" data-background-color="rose">
          <i class="material-icons">place</i>
        </div>
        <div class="card-content">
          <h4 class="card-title">Test</h4>
          <p class="text-center" id="msgModalInsertAgression"></p>
          <br>
          <div class="input-group">
            <span class="input-group-addon"><i class="material-icons">date_range</i></span>
            <div class="form-group">{{ agresionForm.fecha }}</div>
          </div>
        </div>
        <div class="card-footer pull-right">
          <button id="btnInsertModalInsertAgression" type="submit" class="btn btn-fill btn-rose">Insertar</button>
          <button id="btnCloseModalInsertAgression" type="button" class="btn btn-default btn-fill" data-dismiss="modal">Cancelar</button>
        </div>
      </form>
    </div>
  </div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

我在这里找到了解决方案:

  

如果模态容器具有固定或相对位置或位于其中   具有固定或相对位置的元素将发生此行为。   Bootstrap modal appearing under background