Hi, I’ve been using Wix for just about a month, I am trying to figure out how to code this.
- If the input box is empty. show Image1 & hideRepeater1
- if text is inputted, hide image1 & show repeater1, The inputted text in the input box will filter the items in the repeater.
Done with the filtering.
the problem is if the input box is empty, it just shows the whole data from the database.
Thanks in advance.
here’s my code
import wixLocation from ‘wix-location’
import wixData from ‘wix-data’ ;
$w.onReady( function () {
$w( “#input9” ).show();
$w( “#button19” ).hide();
$w( ‘#repeater1’ ).hide();
});
export function input9_keyPress(event) {
let input = $w( “#input9” ).value;
$w( ‘#image1’ ).hide( “fade” );
$w( ‘#repeater1’ ).show( “fade” );
$w( “#dataset1” ).setFilter(wixData.filter().contains( ‘viberPost’ , input));
}
I suspect you will need to force a screen refresh
what you can do is collapse it.
its the same as hidding it, except evrything under it will go up so you don’t have empty spaces where the element is collapsed.
you also don’t have to refresh the screen by doing so.
add this to your onChange() function from the inputfield
if $w(“#input9”).value !== “”){
$w(“#image1”).collapse()
$w(“#repeater1.expand()
} else {
$w(”#image1").expand’()
$w(“#repeater1”).collapse()
$w(“#dataset1”).setFilter(wixData.filter().contains(‘viberPost’,$w(“#input9”).value))
}
It doesn’t work.
thanks tho.
I tried this code, but it displays the repeater if the input box is empty instead of hiding it, and displays the image1 when the text is inputted.
Sorry was on my phone instead of the pc,
this should show repeater when there is input
and hide the image
when there is no input it hide the repeater and shows the inputµ
if $w(" #input9 “).value !== “”){
$w(” #image1 “).expand()
$w(” #repeater1 .collapse()
} else {
$w(" #image1 “).collapse’()
$w(” #repeater1 “).expand()
$w(” #dataset1 “).setFilter(wixData.filter().contains(‘viberPost’,$w(” #input9 ").value))
}
@jhonkellenmenor
glad it worked out,
kristof.
@jhonkellenmenor Hello Mr Kell, could you help me with your code i have the same problem but i cannot make your code work. Maybe you can explain me.