使用模态确认删除

时间:2016-03-24 02:55:42

标签: laravel twitter-bootstrap-3 bootstrap-modal

我正在尝试实施模式框以确认删除。这是我的观察表。

<div class="row">
    <div class="col-lg-12">
        <h2>Daftar User</h2>
        <div class="table-responsive">
            <table class="table table-bordered table-hover">
                <thead>
                    <tr>
                        <th>No.</th>
                        <th>Username</th>
                        <th>Nama</th>
                        <th>Hak_akses</th>
                        <th>Terakhir login</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $no=1;?>
                    @foreach ($user as $data)
                   <tr>
                    <td>{{ $no++ }}</td>
                    <td>{{ $data->username }} </td>
                    <td> {{ $data->name }} </td>
                    <td> {{ $data->hak_akses }} </td>
                    <td> {{ $data->updated_at }} </td>
                    <td><button class="btn btn-warning" data-toggle="modal" data-target="#edituser">Edit</button>
                  <a  class="btn btn-danger" data-toggle="modal" data-target="#hapus ">Hapus</a></td>
                   </tr>
                   @endforeach
                </tbody>
            </table>
            {{$user->render()}}
        </div>
    </div>
</div>

这是我的模态

<div class="modal fade" id="hapus" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        <p>Apakah anda yakin menghapus data user <strong>{{$data->username}}</name> </p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
       <a href="hapus/{{$data->id}} "><button type="button" class="btn btn-primary">Hapus</button></a>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

但是,当我点击&#34; hapus&#34;按钮删除数据,删除按钮链接到最后一个id。所以它与我想要删除的数据不匹配。对这个问题有任何想法吗?

0 个答案:

没有答案