尚筹网:批量删除角色之给批量删除按钮绑定单击响应函数

标记批量删除按钮

/atcrowdfunding-admin-1-webui/src/main/webapp/WEB-INF/role-page.jsp中:

	<button type="button" class="btn btn-danger"
							style="float: right; margin-left: 10px;">
							<i class=" glyphicon glyphicon-remove"></i> 删除
						</button>

变成

<button id="batchRemoveBtn" type="button" class="btn btn-danger"
	style="float: right; margin-left: 10px;">
	<i class=" glyphicon glyphicon-remove"></i> 批量删除
</button>

在这里插入图片描述

检查itemBox是否被选中

/atcrowdfunding-admin-1-webui/src/main/webapp/WEB-INF/role-page.jsp

// 给批量删除按钮绑定单击响应函数
$("#batchRemoveBtn").click(function(){
	
	// 获取被选中的itemBox数组长度
	var length = $(".itemBox:checked").length;
	
	// 如果长度为0,说明没有选择itemBox
	if(length == 0) {
		layer.msg("请至少选择一条!");
		return ;
	}
	// 未完待续...
});

在弹出的模态框中显示confirm信息

在这里插入图片描述

// 给批量删除按钮绑定单击响应函数
$("#batchRemoveBtn").click(function(){
	
	// 获取被选中的itemBox数组长度
	var length = $(".itemBox:checked").length;
	
	// 如果长度为0,说明没有选择itemBox
	if(length == 0) {
		layer.msg("请至少选择一条!");
		return ;
	}
	
	// 在全局作用域内创建roleIdArray
	window.roleIdArray = new Array();
	
	// 遍历$(".itemBox:checked")
	$(".itemBox:checked").each(function(){
		
		// 通过checkbox的roleid属性获取roleId值
		var roleId = $(this).attr("roleid");
		
		// 存入数组
		window.roleIdArray.push(roleId);
		
	});
	
	// 调用函数打开模态框
	showRemoveConfirmModal();
});

在这里插入图片描述

测试是否成功

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值