1.當(dāng)在折疊面板上添加了按鈕疾棵,點(diǎn)擊按鈕時(shí)折疊面板冒泡事件也會觸發(fā)痹仙,隨之打開收起。
TIM圖片20181205104706.png
解決方法:
在按鈕的點(diǎn)擊事件中添加如下語句a/b嗜历,即可阻止冒泡事件抖所。
//a:谷歌瀏覽器有效(火狐無效:因?yàn)闊o法識別window.event)
layui.stope(window.event);
//b:都有效
var evt = window.event || arguments.callee.caller.arguments[0]; // 獲取event對象
layui.stope(evt);
···
2.彈出層get方式傳遞參數(shù):
table.on('tool(role_table)', function(obj){
var data = obj.data;//選中行數(shù)據(jù)
if(obj.event === 'limitRole'){
layer.open({
type: 2,
title:'修改角色信息',
area: ['1200px', '800px'],
fixed: false, //不固定
maxmin: true,
content: "staff_jsqxsz_edit.html?'roleId'="+data.roleId
});
}
}
var searchURL = window.location.search;
searchURL = searchURL.substring(1,searchURL.length);
var roleId=searchURL.substring(searchURL.indexOf("=")+1);
//console.log(roleId);
3.layUI table隱藏某列:
1.隱藏ID列的值
...
, cols: [[ //標(biāo)題欄
{field: 'data_id', title: 'ID', width: 50,style:'display:none;'}
2.隱藏ID列的表頭
$('table.layui-table thead tr th:eq(0)').addClass('layui-hide');
3.js轉(zhuǎn)換數(shù)組類型:
staffRoleIds.map(Number)//轉(zhuǎn)換為Int
4.阻止冒泡事件:
event.stopPropagation();
//======================
$('.imgHover').click(function (event) {
event.stopPropagation();
})