Hi J.D,
Thanks for your reply.
The code I’m working with is below. I’ve removed it and re-added it. However the buttons sticking seem to remain the same.
I have four tag groups - seasonsTags, liturgyTags, sacramentTags, saintsSolemnitiesFeastDayTags.
These are connected to the MusicResources dataset.
Every time I link the values to the dataset three buttons/tags remain checked: Ordinary, All Seasons, Responsorial Psalm. When disconnected they appear normal like all other buttons.
What I’m trying to do is filter a repeater using multiple tag groups.
And also filter/find items with a search bar.
Count the items found.
And use a reset button to start over/reset the tags and the repeater.
This is the vision for the page:
https://timothyhartcreativ.wixsite.com/timothyhart/musicresources-2
I’ve taken the code from a wix tutorial and played around with a number of other examples but can’t get it working.
And now with or without code - those three selection tags are stuck on.
Any wisdom would be greatly appreciated.
With gratitude and kind regards,
Tim.
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
$w ( "#seasontags, #liturgytags, #sacramenttags, #saintsSolemnitiesFeastDaysTags" ). onChange ( function () {
search ();
});
function search () {
let filter = wixData . filter ();
let seasIdx = $w ( "#seasontags" ). selectedIndices ;
let litIdx = $w ( "#liturgytags" ). selectedIndices ;
let sacIdx = $w ( "#sacramenttags" ). selectedIndices ;
let sainIdx = $w ( "#saintsSolemnitiesFeastDaysTags" ). selectedIndices ;
let category = $w ( "#seasontags" ). value ;
let litVal = $w ( "#liturgytags" ). value ;
let sacVal = $w ( "#sacramenttags" ). value ;
let sainVal = $w ( "#saintsSolemnitiesFeastDaysTags" ). value ;
if ( seasIdx . length > 0 || litIdx . length > 0 || sacIdx . length > 0 || sainIdx . length > 0 ) {
filter = filter . hasSome ( "season" , category )
. and ( filter = filter . hasSome ( "liturgy" , litVal ))
. and ( filter = filter . hasSome ( "sacrament" , sacVal ))
. and ( filter = filter . hasSome ( "saintsSolemnitiesFeastDays" , sainVal ))
$w ( "#dataset1" ). setFilter ( filter )
. then ( count )
} **else** {
$w ( "#dataset1" ). setFilter ( filter )
. then ( count )
}
$w ( "#resetfilter" ). onClick ( function () {
$w ( "#seasontags, #liturgytags, #sacramenttags, #saintsSolemnitiesFeastDaystags" ). value = **undefined** ;
$w ( "#dataset1" ). setFilter ( wixData . filter ()). then ( count );
});
}
//COUNT ITEM
function count () {
let count = $w ( "#dataset1" ). getTotalCount ();
if ( count > 0 ) {
$w ( "#countText" ). text = ` ${ count } items found` ;
} **else** { $w ( "#countText" ). text = `No item found` ; }
**return** count ;
}
$w ( "#dataset1" ). onReady ( function () {
count ();
});
});