- table.on('tool(hostTable)', function (obj) {
- var data = obj.data;// 须写
- if (obj.event === 'del') {
- var parents = $(this).parents('.elementClass');
- operateId = $(parents).attr('id');
- layer.confirm('确认删除么', function (index) {
1. 找到删除按钮所在的父元素, 以确定是哪一个表格 table;(表格选择复选框数据动态生成的);
- var parents = $(this).parents('.elementClass');
- operateId = $(parents).attr('id');
- 2.var node = nodes[operateId];//nodes 是整个页面的的所有数据; node 是 nodes 下面的数据, 是一个对象;
- 3.var svcFuncDfs = [];//svcFuncDfs 是 table 表格的所有数据; 按照行来整理的;
- var svcFuncDfData = [];
- 4.if (node != null) {
- svcFuncDfs = node.svcFuncDfs;
- if (svcFuncDfs == null || svcFuncDfs == undefined) {// 如果没有行数据
- svcFuncDfs = [];
- } else {
- for (var i = 0; i < svcFuncDfs.length; ++i) {// 如果有行数据
- if ((svcFuncDfs[i].hostId + svcFuncDfs[i].serverName + svcFuncDfs[i].exeUser + svcFuncDfs[i].exeMachine) != (data.hostId + data.serverName + data.exeUser + data.exeMachine)) {
- svcFuncDfData.push(svcFuncDfs[i]);// 将除了删除掉的这行数据外的其他数据添加入一个新的数组;
- }
- }
- }
- node.svcFuncDfs = svcFuncDfData;// 再放入 node 中;
- nodes[operateId] = node;// 再放入 nodes 中;
- }
- obj.del();.// 删除页面中的元素;
来源: http://www.bubuko.com/infodetail-2626039.html