← API Index · How to use components
filter component #oo-filter
Offers global filtering of the items shown by the shop and search components.
Features:
- depending on the shop's setup it shows filter groups for origin, diet advice, ingredients, …; the groups and their labels are maintained in the backend (see the item labels skill)
- filters of different groups are chained (AND); options selected within one group are alternatives (OR)
- "negative" groups exclude items carrying the label
- the active filters are shown as removable tags, with a "clear all" button
- the selection is stored in the browser and survives page changes and reloads
- the filter pane opens as an overlay (full screen on small devices); the search component's filter button opens it too
Labels used by too few items, and groups hidden in the shop's setup, are shown to administrators only.
How components are mounted, how switch values are resolved and how debug output is enabled is described in the use-js-components skill.
<div id="oo-navi" data-oo-shop-page="shop.html"></div>
<div id="oo-path"></div>
<div id="oo-filter"></div>
<div id="oo-shop"></div>
component switches
This component has no switches of its own.
Events
| Element | Event | Description |
|---|---|---|
#oo-filter |
oo-filter-changed |
Fired with the list of active filters whenever the selection changes. Shop and search re-render on it; your own script may listen too. |
debug options
Debug scope filter (enable with data-oo-debug="true" on the element or debug:filter:all+, see the skill):
| Term | Description |
|---|---|
filter:all |
Groups and labels rendered, checkbox changes, stored / restored selection. |
Design tips
- The filter group with id
0is always the origin (region) group; the other ids depend on the backend. - Labels of a negative group get the class
oo-filter-group-negon their tag — you may indicate this by a line-through.