From c83950425dcf76ab3d81e72ef6ecc65dcf1a540c Mon Sep 17 00:00:00 2001 From: topwms Date: Mon, 4 Mar 2024 01:53:10 +0000 Subject: [PATCH] =?UTF-8?q?dropdown=E7=9A=84close=E6=9B=BF=E4=BB=A3?= =?UTF-8?q?=E5=8E=9F=E6=A3=80=E6=B5=8B=E6=98=AF=E5=90=A6=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- select.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/select.js b/select.js index 3556901..a88deef 100644 --- a/select.js +++ b/select.js @@ -332,20 +332,6 @@ layui.define(['jquery', 'dropdown'],function(exports){ if (that.context.keyword !== '') { searchInput.val(that.context.keyword).focus(); } - - // 检测dropdown的面版是否已关闭 - var i = setInterval(function() { - // 是否已展开 - if (!elem.data('layui_dropdown_index_opened')) { - clearInterval(i); - - that.context.keyword = ''; - that.context.filteredOptions = null; - that.reloadDropdownData(); - - elem.removeClass('multiple-select-panel-opended') - } - }, 100); }, click: function(data, elem) { @@ -379,6 +365,15 @@ layui.define(['jquery', 'dropdown'],function(exports){ // false不关闭面板 return false; + }, + + close: function(elem) { + // 面板关闭后,清空关键词搜索 + that.context.keyword = ''; + that.context.filteredOptions = null; + that.reloadDropdownData(); + + elem.removeClass('multiple-select-panel-opended') } }); };