fix: 预付金模板多选 chosen 选项全选后隐藏搜索框,取消勾选自动恢复
空搜索框无可选项可选时仍占一行(全局 input 152px 撑宽后换行),把控件行撑高一截; 买卖方向/预付金场景这类全选项固定的小多选尤为明显
This commit is contained in:
@@ -631,5 +631,22 @@ $(function () {
|
||||
if (!isNaN(idx)) vue.onUnderlyingTypeChange(idx);
|
||||
});
|
||||
|
||||
//多选 chosen:可选项已全部选中时隐藏搜索框——没有剩余项可选,空搜索框只会把控件撑高一截;
|
||||
//取消勾选后自动恢复。勾选变化会触发原 select 的 jQuery change(trigger_form_field_change),
|
||||
//加载重建/增删区块后的 refreshChosen 会触发 chosen:updated,两处都走这里的委托统一刷新
|
||||
function refreshChosenSearchField(select) {
|
||||
var $sel = $(select);
|
||||
var $container = $sel.next('.chosen-container-multi');
|
||||
if ($container.length === 0) return;
|
||||
var allSelected = $sel.find('option').length > 0 && $sel.find('option:not(:selected)').length === 0;
|
||||
$container.find('li.search-field').toggle(!allSelected);
|
||||
}
|
||||
$(document).on('change chosen:updated', 'select.chosen-select[multiple]', function () {
|
||||
refreshChosenSearchField(this);
|
||||
});
|
||||
|
||||
SetAceDropDown();
|
||||
$('select.chosen-select[multiple]').each(function () {
|
||||
refreshChosenSearchField(this);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -599,5 +599,22 @@ $(function () {
|
||||
if (!isNaN(idx)) vue.onUnderlyingTypeChange(idx);
|
||||
});
|
||||
|
||||
//多选 chosen:可选项已全部选中时隐藏搜索框——没有剩余项可选,空搜索框只会把控件撑高一截;
|
||||
//取消勾选后自动恢复。勾选变化会触发原 select 的 jQuery change(trigger_form_field_change),
|
||||
//加载重建/增删区块后的 refreshChosen 会触发 chosen:updated,两处都走这里的委托统一刷新
|
||||
function refreshChosenSearchField(select) {
|
||||
var $sel = $(select);
|
||||
var $container = $sel.next('.chosen-container-multi');
|
||||
if ($container.length === 0) return;
|
||||
var allSelected = $sel.find('option').length > 0 && $sel.find('option:not(:selected)').length === 0;
|
||||
$container.find('li.search-field').toggle(!allSelected);
|
||||
}
|
||||
$(document).on('change chosen:updated', 'select.chosen-select[multiple]', function () {
|
||||
refreshChosenSearchField(this);
|
||||
});
|
||||
|
||||
SetAceDropDown();
|
||||
$('select.chosen-select[multiple]').each(function () {
|
||||
refreshChosenSearchField(this);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user