如何在单个页面上显示不同的引导程序模式

问题描述 投票:0回答:1

我正在尝试在单个页面上打开多个模式,但是它们的ID相互冲突。我从bootstrap-4文档中获得了此代码,

模式1可以正常工作,但模式2无法正常工作,我希望它们两个都可以单独工作

代码:

modal1

  <button type="button" class="btn btn-success" data-toggle="modal" data-target="#exampleModal">
                  Add New
                </button>

  <!-- Modal Add Owner -->
  <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Add Owner</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form method="POST" action="{{ route('owner.store') }}">
        @csrf
          <div class="form-group">
            <label for="">Add Owner Name</label>
            <input type="text" name="owner_name" class="form-control" id="" placeholder="Owner Name">
          </div>
          <input type="submit" name="submit" class="btn btn-primary" value="submit">
        </form>  
      </div>
        <div class="modal-footer">
        </div>
      </div>
    </div>
  </div>

modal2:

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
                      <a href="{{ route('owner.show', $owner->id)}}" class="btn btn-primary" data-toggle="modalshow" data-target="#exampleModalshow">Show</a>
                    </button>


  <!-- Modal Show Owner-->
  <div class="modal fade" id="exampleModalshow" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabe2" aria-hidden="true">
   <div class="modal-dialog" role="document">
     <div class="modal-content">
       <div class="modal-header">
         <h5 class="modal-title" id="exampleModalLabel">View Owner</h5>
         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form method="POST" action="{{ route('owner.update', $owner->id) }}">
        @csrf
        @method('PATCH')
          <div class="form-group">
            <label for="">Owner Name</label>
            <input type="text" name="owner_name" class="form-control" value="{{ $owner->owner_name }}">
          </div>
          <input type="submit" name="submit" class="btn btn-primary" value="submit">
        </form>  
      </div>
      <div class="modal-footer">
      </div>
    </div>
  </div>
 </div>
laravel bootstrap-4 bootstrap-modal
1个回答
0
投票

更改第二个模式按钮上的data-target以匹配模式ID

<button data-target="#exampleModalshow">
   ... rest of the code
</button>
© www.soinside.com 2019 - 2024. All rights reserved.