多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ### 一、当操作按钮过多时,隐藏的按钮无法监听事件 网上收集的有两种方案: 1.设置样式,禁止按钮过多时应用layui的自动收缩,现象推测是可行的,因为没有收缩时没有这个问题,不过我测试失败,可能是我放置在页面中的位置不对,或使用的方式不对,样式设置如下, ``` <style> .layui-table-col-special .layui-table-cell { height:auto; overflow:visible; text-overflow:inherit; white-space: normal; } </style> ``` 2.通过在layui加载模块后初始化的代码里,加上如下代码,测试有效【注意其中的$ = layui.$】 ``` // 修复按钮过多,导致框架自动折叠,进而导致按钮绑定的事件失效的问题 $(document).off('mousedown','.layui-table-grid-down') .on('mousedown','.layui-table-grid-down',function(event){ table._tableTrCurr = $(this).closest('td'); }); $(document).off('click','.layui-table-tips-main [lay-event]') .on('click','.layui-table-tips-main [lay-event]',function(event){ var elem = $(this); var tableTrCurr = table._tableTrCurr; if(!tableTrCurr){ return; } var layerIndex = elem.closest('.layui-table-tips').attr('times'); // 关闭当前这个显示更多的tip layer.close(layerIndex); table._tableTrCurr.find('[lay-event="' + elem.attr('lay-event') + '"]').first().click(); }); ```