Filters
Filter by a group
Use the filter()
method. If, for example, you wanted to show only items that match "space"
, you would do this:
shuffleInstance.filter('space');
Filter by multiple groups
Show multiple groups at once by using an array.
shuffleInstance.filter(['space', 'nature']);
By default, this will show items that match space
or nature
. To show only groups that match space
and nature
, set the filterMode
option to Shuffle.FilterMode.ALL
.
Show all items
To go back to having no items filtered, you can call filter()
without a parameter, or use Shuffle.ALL_ITEMS
(which by default is the string "all"
).
shuffleInstance.filter(Shuffle.ALL_ITEMS); // or .filter()
Overrides
You can override both Shuffle.ALL_ITEMS
and Shuffle.FILTER_ATTRIBUTE_KEY
if you want.
// Defaults
Shuffle.ALL_ITEMS = 'all';
Shuffle.FILTER_ATTRIBUTE_KEY = 'groups';
// You can change them to something else.
Shuffle.ALL_ITEMS = 'any';
Shuffle.FILTER_ATTRIBUTE_KEY = 'categories';
Then you would have to use data-categories
attribute on your items instead of data-groups
.