不是从 bootstrap 模态中删除

Is not deleting from bootstrap modal

正如你所看到的这些代码,分页中的删除按钮在没有 bootstrap 模态的情况下工作正常,然后转换为 bootstrap 模型,bootstrap 模型一次工作正常单击删除按钮,但问题不是删除它或什么都不做。我不知道我错过了什么,我可能是身份证号或 jquery,我急需帮助。

Foreach

              <thead>
              <tr class="center">
                <th>ID</th>
                <th>Account ID</th>
                <th>Password</th>
                <th>Company Name</th>
                <th>Restocking Fee</th>
                <th>Status</th>
                <th>Action</th>
              </tr>
              </thead>
              <tbody>
                @foreach($resellers as $reseller)
              <tr>
                <td>{{ $reseller-> id }}</td>
                <td>{{ $reseller-> accountid }}</td>
                <td>{{ $reseller-> password }}</td>
                <td>{{ $reseller-> companyname }}</td>
                <td>{{ $reseller-> restockingfee }}</td>
                <td>{{ $reseller-> active}}</td>
                <td class="center">

                    <form action="{{ url('/admin/resellers', $reseller->id) }}" method="POST">
                    <strong><a href="/admin/resellers/{{ $reseller->id }}" class="btn btn-primary btn-sm btn-mini" >
                        <i class="fas fa-pen fa-fw"></i>View</a></strong>
                    @method('DELETE')
                    @csrf
                    <button class="btn btn-secondary btn-sm btn-mini"><i class="far fa-edit fa-fw"></i>Edit


<a href="#" style="color:black; font-weight: bold;" data-href="{{ url('/admin/resellers/{reseller}', $reseller->id) }}"
     class="btn btn-info btn-outline btn-circle btn-lg" data-toggle="modal" data-target="#myModal" title="Delete">Delete</a>
                </form>

                </td>
              </tr>

                @endforeach
              </tbody>

              <tfoot>
              <tr>
                <th>ID</th>
                <th>Account ID</th>
                <th>Password</th>
                <th>Company Name</th>
                <th>Restocking Fee</th>
                <th>Status</th>
                <th>Action</th>
              </tr>
              </tfoot>
            </table>
          </div>

模态

<!-- Delete Modal -->
<div class="container">
    <div class="modal fade" id="myModal" role="dialog">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Delete !!!</h4>
          </div>
          <div class="modal-body text-center">
            <p class="my-0 font-weight-bold">Are you sure you want to delete this data???</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <a class="btn btn-danger btn-ok">Delete</a>
          </div>
        </div>
      </div>
    </div>
  </div>

jquery

<script>
  $('#myModal').on('show.bs.modal', function(e) {
      $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
  });
</script>

控制器

   public function destory(\App\Reseller $reseller){

        $reseller -> delete();

        return redirect ('/admin/resellers');
    }

在您的 blade 上,在 form 之外执行此操作(不在表格中):


@foreach($resellers as $reseller)
  <tr>
    <td>{{ $reseller->id }}</td>
    <td>{{ $reseller->accountid }}</td>
    <td>{{ $reseller->password }}</td>
    <td>{{ $reseller->companyname }}</td>
    <td>{{ $reseller->restockingfee }}</td>
    <td>{{ $reseller->active}}</td>
    <td class="center">

      <a href="#" style="color:black; font-weight: bold;" data-href="{{ url('/admin/resellers/', $reseller->id) }}" class="btn btn-info btn-outline btn-circle btn-lg" data-toggle="modal" data-target="#myModal" title="Delete">Delete</a>

    </td>
  </tr>
@endforeach

这是模态数据:

<!-- Delete Modal -->
<div class="container">
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Delete !!!</h4>
        </div>
        <div class="modal-body text-center">
          <p class="my-0 font-weight-bold">Are you sure you want to delete this data???</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <a class="btn btn-danger btn-ok">Delete</a>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- Delete Modal JS -->
<script>
  $('#myModal').on('show.bs.modal', function(e) {
      $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
  });
</script>