mirror of
https://github.com/layui/layui.git
synced 2026-02-09 02:09:18 +08:00
fix(table): 修复表头同时开启 sort 和 colTool 时的事件冒泡问题 (#2954)
* fix(table): 修复表头同时开启 sort 和 colTool 时的事件冒泡问题 * Update src/modules/table.js Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -306,8 +306,9 @@
|
||||
},
|
||||
{
|
||||
field: 'sex',
|
||||
title: '性别',
|
||||
width: 80,
|
||||
title:
|
||||
'性别 <i class="layui-icon layui-icon-female" lay-event="gender"></i>',
|
||||
width: 100,
|
||||
edit: 'text',
|
||||
sort: true,
|
||||
escape: false
|
||||
@@ -673,7 +674,13 @@
|
||||
|
||||
// 表头自定义元素工具事件
|
||||
table.on('colTool(test)', function (obj) {
|
||||
var event = obj.event;
|
||||
console.log(obj);
|
||||
if (event === 'gender') {
|
||||
layer.alert(layui.util.escape(JSON.stringify(obj.col)), {
|
||||
title: '当前列属性'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 触发单元格工具事件
|
||||
|
||||
@@ -2875,7 +2875,12 @@ layui.define(
|
||||
var nowType = elemSort.attr('lay-sort');
|
||||
var type;
|
||||
|
||||
// 排序不触发的条件
|
||||
// 表头工具元素不触发排序
|
||||
if ($(e.target).closest('[lay-event]')[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 其他条件不触发排序
|
||||
if (!elemSort[0] || othis.data('resizing') === 1) {
|
||||
return othis.removeData('resizing');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user