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.
#2. Select the data to be deleted in batches.
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
4. The result interface after batch deletion.
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:'错误'}); }); }
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); //更新当前页 }); }
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.