gpt4 book ai didi

javascript - 在 Codeigniter 中使用模态 Bootstrap 作为删除提示

转载 作者:行者123 更新时间:2023-12-03 02:50:24 25 4
gpt4 key购买 nike

大家好,我在 CI 脚本上使用 Modal 作为删除提示,但它不起作用,也许有错误。任何人都可以帮我检查代码。

我的删除按钮代码:

<a onclick="confirm_modal(<?php echo base_url('threads/deletereplytopic/'.$toprep['id']) ?>)" style="cursor:pointer;" data-toggle="modal"  data-target="#deleteReplyTopic"><i class="fa fa-trash-o" aria-hidden="true"></i></a>

我的 Modal 和 Js 代码:

<!-- Delete Topic Reply  Modal-->
<div class="modal fade" id="deleteReplyTopic" style="display: none;" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title"><?php echo lang_key('confirm_delete'); ?></h6>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<?php echo lang_key('confirm_delete_text'); ?>
</div>
<div class="modal-footer">
<a class="btn btn-danger" id="delete_topic_reply" href=""><?php echo lang_key('delete'); ?></a>
<button type="button" class="btn btn-info" data-dismiss="modal" id="delete_cancel_link"><?php echo lang_key('cancel'); ?></button>
</div>
</div>
</div>
</div>

和 Js:

<!-- Delete Topic JS -->
<script>
function confirm_modal(delete_url)
{
jQuery('#deleteReplyTopic').modal('show', {backdrop: 'static',keyboard :false});
jQuery("#deleteReplyTopic .grt").text(title);
document.getElementById('delete_topic_reply').setAttribute("href" , delete_url );
document.getElementById('delete_topic_reply').focus();
}
</script>

这是我的 Controller 代码:

public function deletereplytopic($id='') {

$deletereply = array(
'id' => $id,
'status' => 0
);
$deltop = 'confirmdelete';
$this->session->set_flashdata('deltop', $deltop);
$this->topic_model->deleteReplyTopic($deletereply);
}

如果我直接删除数据,这个 Controller 代码可以工作,但如果我使用模态则不起作用..我希望有人可以帮助我..

最佳答案

您缺少引号,例如confirm_modal('某事')

<a onclick="confirm_modal('<?php echo base_url('threads/deletereplytopic/'.$toprep['id']) ?>')" style="cursor:pointer;" data-toggle="modal"  data-target="#deleteReplyTopic"><i class="fa fa-trash-o" aria-hidden="true"></i></a>

关于javascript - 在 Codeigniter 中使用模态 Bootstrap 作为删除提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47897355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com