jquery - 不从引导模式中删除

标签 jquery laravel bootstrap-modal delete-row

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

前缘

              <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>

j查询

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

Controller

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

        $reseller -> delete();

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

最佳答案

在你的 Blade 上,在 form 之外(不是在 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>

关于jquery - 不从引导模式中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63452799/

相关文章:

javascript - 仅对父元素实现 css

Laravel - Pusher - 检测用户何时离开网站或离开页面

mysql - Left Join with group by 跳过groupby

laravel - 使用 Mix/Webpack 将 quill.js 导入 Laravel

javascript - 从 js 函数调用引导模式

javascript - 如何在ajax请求完成时关闭甜蜜警报

jquery - .scrollLeft() 在 Chrome (Jquery) 中不起作用

php - 通过唯一ID动态加载MySQL数据到Bootstrap模态-CodeIgniter

html - 如何翻转div标签内的文字?

javascript - 奇怪的 $.post 行为