当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Bootstrap open 2 different modal dialogs same page

问题描述:

I have a page where I want to launch 2 different modal windows. One for creating new users and one for editing existing users.

I show existing users in a clickable table and link to my modal #edit like this:

<tr data-id="<?php echo $value['id'];?>" data-toggle="modal" data-target="#edit" class="open-edit">

This opens my Bootstrap modal dialog:

<div class="modal fade" id="edit">

<div class="modal-dialog">

<div class="modal-content">

<div class="modal-header">

<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

I ommited the rest of the code.. I grab this modal on its id="edit".

This works like I want - when clicking on the table entry, the modal dialog gets opened with a form I created.

Now I created an exact copy of this modal dialog, only changed the id="edit" to id="create" and created this button:

<button class="btn btn-primary btn-me" data-toggle="modal" data-target="#create" >Create user<i class="fa fa-arrow-circle-right"></i></button>

I would think that it would now simply open my second modal dialog named #create, but instead it blanks out the screen, like when a modal dialog shows - but without showing any modal window/dialog.

Can anyone help me understand why this is happending or what I am doing wrong?

网友答案:

this code open 2 modal dialogs in the same page

<button type="button" class="btn btn-success btn-sm" style="width: 100%;" data-toggle="modal" data-target="#modal1">modal1</button>

<button type="button" class="btn btn-success btn-sm" style="width: 100%;" data-toggle="modal" data-target="#modal2">modal2</button>

<div class="modal fade" id="modal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title" id="myModalLabel"></h4>
          </div>
          <div class="modal-body">

          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Chiudi</button>
          </div>
        </div>
      </div>
    </div>



<div class="modal fade" id="modal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title" id="myModalLabel"></h4>
          </div>
          <div class="modal-body">

          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Chiudi</button>
          </div>
        </div>
      </div>
    </div>
分享给朋友:
您可能感兴趣的文章:
随机阅读: