繁体   English   中英

Noty jQuery-通知外观

[英]noty jQuery - notification apearence

我想在删除所有按钮上显示通知。 我单击通知的“删除所有按钮”时,仅使用noty jquery ,通知显示的按钮不完整,页面已重定向,但我正在使用codeigniter来执行以下代码

在此处输入图片说明

// view of my file
<?php $page_url = $this->uri->segment(2);?>

<div id="contents" style="width:1024px;">

    <div class="buttons">

        <div><button class="button-choose-2 pure-button" id="delete">Delete</button></div>

        <div>
            <input type="button" class="button-choose-2 pure-button" name="CheckAll" value="Check All" onClick="checkAll(document.myform.list)"></div>
        <div>
            <input type="button" class="button-choose-2 pure-button" name="UnCheckAll" value="Uncheck All" onClick="uncheckAll(document.myform.list)"></div>

        <div><a href="parexons_con/add_team"><button class="button-choose-2 pure-button">Add</button></a></div>
    </div>

    <br style="clear:both;">
    <?php $this->load->view("includes/left_menu") ?>
    <form name="myform" id="myform">
        <div class="right-contents">
            <table width="98%" cellpadding="5">
            <tr class="right-top">
                    <td width="8%">&nbsp;</td>
                    <td width="21%">Name</td>
                    <td width="18%">Image</td>
                    <td width="38%">Designation</td>
                    <td colspan="3" align="center">Actions</td>

                </tr>

                <?php if(is_array($items)): ?>

                <?php foreach($items as $row){?>
                <tr>

                    <td width="8%"><input type="checkbox" id="list"  name="del[]" value="<?php echo $row->team_id;?>" class="del"></td>

                    <td width="21%"><?php echo $row->name?></td>

                    <td width="18%"><img src="assets/icons/<?php echo $row->photo?>" width="100" height="70"></td>

                    <td width="38%"><?php echo $row->designation?></td>

                    <td width="5%"><a href="parexons_con/edit_team/<?php echo $row->team_id; ?>"><img src="assets/img/edit.png"></a></td>

                    <td width="5%"><img src="assets/img/27935.png"></td>

                    <td width="5%"><a href="parexons_con/delete/<?php echo 
$row->team_id;?>/<?php echo $page_url ?>/<?php echo 'team'; ?>/<?php echo 'team_id'; ?>"><img src="assets/img/Delete-icon.png"></a></td>
                </tr>

                <?php } endif; ?>
            </table>
        </div>
</form>

    <script>
        function checkAll(field)
        {
            for (i = 0; i < field.length; i++)
                field[i].checked = true ;
        }

        function uncheckAll(field)
        {
            for (i = 0; i < field.length; i++)
                field[i].checked = false ;
        }
    </script>
</div>

</div>
<script type="text/javascript">

    $(document).ready(function(){

        $("#delete").on('click', function(e) {
            var r =  confirm("are you sure you want to delete this");

            if (r==true) {
                e.preventDefault();

                var ids = $('.del:checked').map(function () {
                    return this.value;

                }).get();
                console.log(ids);

                $.ajax({
                    type: "POST",
                    url: "<?php echo base_url(); ?>parexons_con/delete_all",

                    data: 'id=' + ids,
                    type: "POST",


                    success: function (result) {


                        noty({text: 'thank you for providing information', type: 'success',settimeout:5000});


                        setTimeout(window.location.reload(), 1200000);

                    }
                });
            }
            });
    });



</script>

和控制器是

function delete_all($del_id = NULL, $view = NULL, $table = NULL, $field_name = NULL)
{

$error = 'error';
$msg = 'deleted';

$ids = $this->input->post('id');
$explode = explode(",", $ids);
foreach ($explode as $id) {
    $query = $this->parexons_model->delete_row('team', array('team_id' => $id));

}

if ($query) {
    http_response_code(redirect("my_controller/team"), 5000);
} else {
    redirect("my_controller/team");
}
}

jQuery ajax数据的语法错误

data: {id: ids},

其次,不要重定向控制器功能,您需要将一些值传递给ajax成功,例如

function delete_all($del_id = NULL, $view = NULL, $table = NULL, $field_name = NULL) {
$error = 'error';
$msg = 'deleted';
$ids = $this->input->post('id');
$explode = explode(",", $ids);
foreach ($explode as $id) {
    $query = $this->parexons_model->delete_row('team', array('team_id' => $id));

}
if ($query) {
   echo "success";
} else {
   echo "false";
}
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM