轉載於:https://blog.csdn.net/hukechui5880/article/details/90268361
如何讓表格的工具按鈕列顯示更多的時候也能點擊觸發table的事件
layUI列表中,操作欄按鈕過多時會自動隱藏,點擊彈出隱藏按鈕后,按鈕本身綁定得監聽事件失效.(原文鏈接)
效果圖:
解決思路可點擊原文連接查看,具體解決方法如下:
//將以下代碼粘入相關頁面中 $(document).off('mousedown','.layui-table-grid-down'). on('mousedown','.layui-table-grid-down',function (event) { table._tableTrCurrr = $(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 tableTrCurrr = table._tableTrCurrr; if(!tableTrCurrr){ return; } var layerIndex = elem.closest('.layui-table-tips').attr('times'); console.log(layerIndex); layer.close(layerIndex); table._tableTrCurrr.find('[lay-event="' + elem.attr('lay-event') + '"]').children("i").first().click(); }); //############################按鈕監聽方法########################################### //監聽按鈕事件方法 注意tool(test)中的test應和table中lay-filter對應 table.on('tool(test)',function(obj){ var d = obj.data; if(obj.event === ''){//event對應按鈕中的lay-event //業務操作 }
————————————————
版權聲明:本文為CSDN博主「劉大壯的快樂生活」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/hukechui5880/article/details/90268361