Home >Web Front-end >Layui Tutorial >How to refresh the current page for batch deletion in layui

How to refresh the current page for batch deletion in layui

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-07-11 14:09:474617browse

How to refresh the current page for batch deletion in layui

1. First perform the visual interface operation, as shown in the figure, there are 2 pieces of data.

How to refresh the current page for batch deletion in layui

#2. Select the data to be deleted in batches.

How to refresh the current page for batch deletion in layui

3. Click the delete button and a prompt code will pop up

layer.confirm("确认删除勾选的专题?", {icon: 3, title:"确认"}, function(){
      batchDel(resSubInfoIds);
     }, function(){
 });

batchDel calls the real batch deletion method

How to refresh the current page for batch deletion in layui

4. The result interface after batch deletion.

How to refresh the current page for batch deletion in layui

Related recommendations: "layui Framework Tutorial"

5. The method of adding data will be used when deleting batches later. This, so this method is reused and will be used during the initial data loading and batch deletion processes:

function load(pageNum, params){
params = params || {};
params.current = pageNum;
$.post(ctxBack+"/XXXXXX/list", params, function(result){
    if(false === result.success){
    layer.alert(result.message || "专题数据加载失败", {icon: 2,title:'错误'});
    return;
    }
    laytpl(gridTpl).render(result.data.records, function(html){
        $(gridPanelId + " table tbody").empty().append(html);
    });
   
    //缓存查询参数
        gridParams.page = result.data.current;
        gridParams.params = params;
   
    renderPage($(gridPanelId + " .panel-footer"), result.data, load, params);
}).error(function(){
layer.alert("专题数据加载失败", {icon: 2,title:'错误'});
});
}

How to refresh the current page for batch deletion in layui

6. The deletion method, refreshing after batch deletion, is actually Request the initialization method again to load the data once. Use the ajax method to achieve no page refresh. The code is as follows:

/**
     * 删除专题
     */
    function del(){
    var resSubInfoIds=getCheckedData();
    if(resSubInfoIds == ""){
    layer.msg("请选择需要删除的专题");
    return ;
    }
    layer.confirm("确认删除勾选的专题?", {icon: 3, title:"确认"}, function(){
      batchDel(resSubInfoIds);
     }, function(){
 });
   
    }
/**
     * 批量删除
     */
    function batchDel(resSubInfoIds){
    var loading = layer.load(2, { shade: [0.3,'#fff']});
    params={resSubInfoIds:resSubInfoIds};
    $.post(ctxBack+"/XXXXXX/batchDel", params, function(result){
    if(false === result.success){
    layer.alert(result.message || "专题删除失败", {icon: 2,title:'错误'});
    return;
    }
    layer.msg("专题删除成功");
}).error(function(){
layer.alert("专题删除失败", {icon: 2,title:'错误'});
}).complete(function(){
layer.close(loading); //加载完成关闭loading
load(gridParams.page, gridParams.params); //更新当前页
});
    }

How to refresh the current page for batch deletion in layui

The above is the detailed content of How to refresh the current page for batch deletion in layui. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is layui iconNext article:what is layui icon