Would any one be able to help with the below code please?
I have various hide/show elements to a page - the majority of the code works perfectly - I just can’t seem to re-hide the repeater after it has listed the first set of results. I would like the repeater to be hidden once again when a site user click on a #Letter again.
Any help will be fab.
import { local } from ‘wix-storage’ ;
import wixData from ‘wix-data’ ;
$w . onReady ( function (){
$w ( “#Letter1, #Letter2, #Letter3, #Letter4, #Letter5, #Letter6, #Letter7, #Letter8, #Letter9, #Letter10, #Letter11, #Letter12, #Letter13, #Letter14, #Letter15, #Letter16, #Letter17, #Letter18, #Letter19, #Letter20, #Letter21, #Letter22, #Letter23, #Letter24, #Letter25, #Letter26” ). onClick (( event ) => {
$w ( “#repeater1” ). hide
let targetId = event . target . id ;
let id = Number ( targetId . split ( “Letter” )[ 1 ]);
for ( let i = 1 ; i < 27 ; i ++){
if ( i === id ){
$w ( “#Author” + i ). hidden ? $w ( “#Author” + i ). show ():
$w ( “#Author” + i ). hide ();
}
else {
$w ( “#Author” + i ). hide ();
}
}}
)
$w ( “Button” ). onClick ( ( event ) => {
let value = event . target . id ;{
wixData . query ( ‘Repository’ ). contains ( ‘author’ , value )
. find ()
. then ( ( results ) => {
let resultcount = results . totalCount ;
$w ( ‘#repeater1’ ). data = results . items ;
{ if ( $w ( “#repeater1” ). hidden ){
$w ( “#repeater1” ). show ();}
}
**if** ( $w ( "#Letter1, #Letter2, #Letter3, #Letter4, #Letter5, #Letter6, #Letter7, #Letter8, #Letter9, #Letter10, #Letter11, #Letter12, #Letter13, #Letter14, #Letter15, #Letter16, #Letter17, #Letter18, #Letter19, #Letter20, #Letter21, #Letter22, #Letter23, #Letter24, #Letter25, #Letter26" ). onCick (( event ) =>
{ $w ( "#repeater1" ). hide ();
}
))
})
}}
)
}
)