English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

bootstrapのモーダルボックス、モーダルボックスの属性の詳細な例

仕事でモーダルボックスが必要な場合は見てみてください

<div class="modal fade" id="userModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true" id="btnCancel">
            ×
          </button>
          <h4 class="modal"-title" id="myModalLabel">
            前台菜单管理
          </h4>
        </div>
          <div class="modal-body">
            <div>
              <table width="100%" border="0" class="userCon_2">
                <tr>
                  <th width="30%">名称:</th>
                  <td width="70%">
                    <input type="text" name="Name" class="form-control" style="border-radius:3px; width:220px;" id="txtName" required="" aria-required="true">
                  </td>
                </tr>
                <tr>
                  <th>动作类型:</th>
                  <td>
                    <select class="selectpicker show-tick" id="txtType" style="height: 30px; width: 220px;" name="Type">
                      <option value="view">view</option>
                      <option value="click">click</option>
                    </select>
                  </td>
                </tr>
                <tr>
                  <th>路径:</th>
                  <td>
                    <input type="text" name="Url" class="form-control" style="border-radius:3px; width:220px;" id="txtUrl" required="" aria-required="true" />
                  </td>
                </tr>
                <tr>
                  <th>排序:</th>
                  <td>
                    <input type="text" name="Rank" class="form-control" style="border-radius:3px; width:220px;" id="txtRank" />
                    <input type="hidden" name="MainMenuGuid" value="" id="txtMainMenuGuid" />
                  </td>
                </tr>
              </table>
            </div>
          </div>
          <div class="modal-footer" style="border-top:none;">
            <button type="button" class="btn btn-default" data-dismiss="modal" id="btnClose">关闭</button>
            <button type="submit" class="btn btn-primary" id="btnSave">保存</button>
          </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal -->
  </div>

モーダルボックスには、カバーレイヤーをクリックしてもモーダルボックスが閉じないようにする属性があります。それはdivで設定された data-backdrop="static"。これにより、モーダルボックス内で内容を入力しているときの突然の誤操作でモーダルボックスが閉じないようにしています。

また、別の属性があります:data-keyboard="false"。これにより、ESCキーを押しても無効になります。同時に、突然の誤操作でモーダルボックスが閉じないようにしています。

<div id="toolbar" class="btn-group">
      <button id="btn_add" type="button" class="btn btn-newAdd" data-toggle="modal" data-target="#userModal">
        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>追加
      </button>
      <button id="btn_edit" type="button" class="btn btn-newAdd">
        <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>修正
      </button>
      <button id="btn_delete" type="button" class="btn btn-newAdd">
        <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>削除
      </button>
</div>

ボタン属性 data-toggle="modal" data-target="#userModal"はモーダルボックスを開くためです。

声明:この記事の内容はインターネットから取得しており、著作権者はすべて所有しています。インターネットユーザーが自発的に貢献し、アップロードしたものであり、このサイトは所有権を持ちません。また、人工的な編集は行われていません。著作権侵害の可能性がある内容を見つけた場合は、notice#wにメールを送ってください。3codebox.com(メール送信時、#を@に変更して報告してください。関連する証拠を提供し、一旦確認がついたら、このサイトは即座に侵害される内容を削除します。)

基礎教程
おすすめ