未从引导程序模式中删除 [英] Is not deleting from bootstrap modal

查看:48
本文介绍了未从引导程序模式中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如您所见,这些代码在没有引导程序模版的情况下在分页中的删除按钮可以正常工作,然后转换为引导程序模型,单击删除按钮后,引导程序模型可以正常工作,但是问题不在于删除它或执行没有什么.我不知道自己想念的是什么,我可能是身份证号码或jquery,我急需帮助.

as you can see these code, the deleting button inside of pagination works fine without bootstrap modal, and then convert to bootstrap model, the bootstrap model is working fine once click the delete button, but the problem is not deleting it or do nothing. I can't figure out what I missing, I could be id number or jquery, I need help badly.

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');
    }

推荐答案

在刀片上,在 form 之外(不在表单中)执行此操作:

On your blade, do this outside the form (not in 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>

这篇关于未从引导程序模式中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆