dth62818 2017-12-20 00:54
浏览 61
已采纳

在Codeigniter中使用模态引导作为删除提示

Hello everyone I use the Modal as a delete prompt on my CI script but its not working maybe there is an error on it. Anyone can check the codes for me.

My codes on delete button:

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

And my Codes in Modal an 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>

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

And here is my Controller codes:

public function deletereplytopic($id='') {

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

This controller codes is working if I directly delete the data but if I use modal is not working..I hope someone can help me..

  • 写回答

2条回答 默认 最新

  • dttnb997315 2017-12-20 03:32
    关注

    You are missing quotes inside e.g. confirm_modal('something')

    <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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效