-
Notifications
You must be signed in to change notification settings - Fork 684
Open

Description
if (term) { |
This condition MUST be removed.
Use case : to manage in proper way the "minimum" of checked elements, by default I hide "Check all" and show only if that necessary for finded term. If I remove the term, no only one event is runned and I have no way to capture that filter is empty to adapt UI :(
Example of what I have
let findElementUncheckAll = context => {
return $('.ui-multiselect-header li:nth-child(2)', $(context).multiselect("widget"));
};
let getMinimum = context => {
return ($(context).data('namespace-type-multiselect-minimum') || 0)*1;
};
$('select[multiple="multiple"][data-namespace-type-multiselect]').multiselect({
click: function(e){
let minimum = getMinimum(this);
if( $(this).multiselect("widget").find("input:checked").length < minimum ){
return false;
}
},
create: function(e){
$('.ui-multiselect-header li:nth-child(3)', $(this).multiselect("widget")).hide();
},
beforeopen: function(e){
let $uncheckAll = findElementUncheckAll(this);
$uncheckAll.hide();
}
}).multiselectfilter({
filter: function(e, matches){
let $that = $(this);
let $widget = $that.multiselect("widget");
let listChecked = $that.multiselect("getChecked");
let $uncheckAll = findElementUncheckAll(this);
let matchCount = 0;
let minimum = getMinimum(this);
for(const [key, value] of Object.entries(matches)) {
if( key.match(/^[0-9]+$/) && value.length > 0 && $(value).is(':checked') ){
++matchCount;
}
}
$uncheckAll.hide();
if(
matchCount
&& listChecked.length - matchCount > minimum
){
$uncheckAll.show();
}
}
});
Metadata
Metadata
Assignees
Labels
No labels