Utilising 'selection tag' input to filter repeater instead of dropdown

So I’ve finally got my database to get filtered on a dynamic page by Search OR Drop Down.
And after learning this I realise I really need to do it with ‘Selection Tags’.

Obviously my hopes it would be the same code and just change the type of input bar were high, and wrong.

Is this a simple bit of re-coding or does it need a complete rework?
Current code below:
Thanks muchly:-)

import wixData from “wix-data” ;

$w.onReady(() => {
wixData.query( ‘TheWhosHoo’ )
.find()
.then(res => {
let options = [{ “value” : ‘’ , ‘label’ : ‘All Categories’ }];
options.push(…res.items.map(title => {
return { ‘value’ : title.entertainmentCategory, ‘label’ : title.entertainmentCategory};
}));
$w( ‘#CategoryDropDown’ ).options = options;
})
});

let lastFilterentertainmentCategory;
let lastFiltertitle;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w( ‘#iTitle’ ).value, lastFilterentertainmentCategory);
}, 200 );
}

function filter(title, entertainmentCategory) {
if (lastFiltertitle !== title || lastFilterentertainmentCategory !== entertainmentCategory) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains( ‘title’ , title);
if (entertainmentCategory)
newFilter = newFilter.eq( ‘entertainmentCategory’ , entertainmentCategory)
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFiltertitle = title;
lastFilterentertainmentCategory = entertainmentCategory;
}
}
export function CategoryDropDown_click(event, $w) {
filter(lastFiltertitle,$w( ‘#CategoryDropDown’ ).value);
}

1 Like