javascript - 如何在 codeigniter 中使用 jquery-confirm?

标签 javascript php jquery html codeigniter

我一直在尝试使用 https://craftpip.github.io/jquery-confirm/#ajaxloading 提供的 jquery-confirm .没有错误,但是一旦我尝试删除一个项目,jquery 会弹出一个警告,但是当我单击“确定”时它不会删除该项目。我不知道错误在哪里。感谢您的帮助

这是PHP代码:

<div class="box">
    <div class="box-body">
        <a href="<?php echo base_url(); ?>admin/inputrequest" class="btn bg-green btn-flat">Input Request</a>
        <br><br>
        <table id="tabelrequest" class="table table-bordered table-striped">
            <thead>
                <tr>
                    <th>No.</th>
                    <th>Item Code</th>
                    <th>Description</th>
                    <th>Qty</th>
                    <th>Delete</th>
                    <th>Edit</th>
                    <th>Photo</th>
                </tr>
            </thead>
            <tbody>
                <?php
                    $no = 1;
                    foreach($allrequest as $request)
                    {
                        $delete_url = base_url().'admin/deleterequest/'.$request->id_request;
                        $update_url = base_url().'admin/updaterequest/'.$request->id_request;
                        $add_url = base_url().'admin/datafotorequest/'.$request->id_request;
                ?>
                        <tr>
                            <td><?php echo $no; ?></td>
                            <td><?php echo $request->item_code; ?></td>
                            <td><?php echo $request->description; ?></td>
                            <td><?php echo $request->qty; ?></td>
                            <td class="col-xs-1" style="text-align: center;"><a class="btn bg-olive btn-flat" class="delete" data-title="Are you sure you want to delete this item?" name="delete" href="<?php echo $delete_url; ?>"><i class="glyphicon glyphicon-trash"></i></a></td>
                            <td class="col-xs-1" style="text-align: center;"><a class="btn bg-teal btn-flat" name="update" href="<?php echo $update_url; ?>"><i class="glyphicon glyphicon-pencil"></i></a></td>
                            <td class="col-xs-1" style="text-align: center;"><a class="btn bg-red btn-flat" name="add" href="<?php echo $add_url; ?>"><i class="glyphicon glyphicon-camera"></i></a></td>
                        </tr>
                <?php
                        $no++;
                    }            
                ?>
            </tbody>
        </table>    
    </div>
</div>

这是我从 jquery-confirms.js 中获取的 jquery

<script>

    $('#delete').confirm({
        content: "",
    });
    $('#delete').confirm({
        buttons: {
            hey: function(){
                location.href = this.$target.attr('href');
            }
        }
    });

</script>

最佳答案

代替这个

<td class="col-xs-1" style="text-align: center;">
    <a class="btn bg-olive btn-flat" class="delete" data-title="Are you sure you want to delete this item?" name="delete" href="<?php echo $delete_url; ?>">
        <i class="glyphicon glyphicon-trash"></i>
    </a>
</td>

我将使用 (onclick="return confirm()")

<td class="col-xs-1" style="text-align: center;">
    <a class="btn bg-olive btn-flat" class="delete" onclick="return confirm('Are you sure you want to delete this item?');"  href="<?php echo $delete_url; ?>">
        <i class="glyphicon glyphicon-trash"></i>
    </a>
</td>

关于javascript - 如何在 codeigniter 中使用 jquery-confirm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48859381/

相关文章:

PHP日期差异错误

PHP多重查询的性能和速度?

jquery - 选择组合后重新加载div

jquery - 信息栏是如何工作的,就像您赢得徽章时出现在 stackoverflow 中的那个?

javascript - ES6中同步加载运行时确定名称的模块

javascript - 如何使 Angular ui-router 父状态在状态更改时始终执行 Controller 代码?

PHP 事务和 mysqli_insert_id

javascript - 如何检查 jQuery 变量的 innerHTML 区域

javascript - 将文本插入所见即所得编辑器问题

javascript - 使用 createElement 创建一个按钮,然后更改其颜色