hide disabled selec2 filter options
This commit is contained in:
parent
a407e6825f
commit
2953301b08
21
hide-disabled-filter-options-for-select2/README.md
Normal file
21
hide-disabled-filter-options-for-select2/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
By default, Select2 doesn't hide any empty filter options. Instead, it makes them disabled which prevents clicking them. This works well when you only have a few filter options but for large filter options, it might be better to hide them instead.
|
||||
|
||||
### If you want to hide the disabled filter options globally, use [this CSS](hide-globally-style.css):
|
||||
|
||||
```css
|
||||
/* Hide disabled (empty) options for select2 globally */
|
||||
.select2-results__option--disabled {
|
||||
display: none;
|
||||
}
|
||||
```
|
||||
|
||||
### If you want to hide the disabled filter options for particular filter or filter item, use [this CSS](hide-specific-filters-style.css):
|
||||
|
||||
```css
|
||||
/* Hide disabled (empty) options for select2 in specific filters only */
|
||||
/* Add the class hide-empty-select2-options to a Filter Posts module or to a particular Filter Item to hide empty options for that particular Filter Posts module or Filter item only */
|
||||
.hide-empty-select2-options .select2-results__option--disabled {
|
||||
display: none;
|
||||
}
|
||||
```
|
||||
Add this CSS class to the Filter Posts module or the Filter Item: `hide-empty-select2-options`.
|
||||
@ -0,0 +1,4 @@
|
||||
/* Hide disabled (empty) options for select2 globally */
|
||||
.select2-results__option--disabled {
|
||||
display: none;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
/* Hide disabled (empty) options for select2 in specific filters only */
|
||||
/* Add the class hide-empty-select2-options to a Filter Posts module or to a particular Filter Item to hide empty options for that particular Filter Posts module or Filter item only */
|
||||
.hide-empty-select2-options .select2-results__option--disabled {
|
||||
display: none;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user