I have looked absolutely everywhere. I have tried a couple of the suggestions I have seen in some somewhat similar posts. I am getting nothing. How do you code it to remove search bar memory without a clear button, but when a member leaves the page? Does anyone know how to do this? It seems like it would be simple, but I am having no success at all.
Look at it from the other direction… If you want to clear the search bar when leaving the page, that means that anyone returning to the page would expect to have a cleared search bar.
Therefore, just clear the search bar when the page is loaded.
I don’t know why I wrote it like this. I did mean when it loaded. I have tried everything and I cannot get it cleared at page load. Sorry. Wrote this while sleep deprived.
@njo Well, in order to help we’ll need more information. How are you clearing? Share your code in a code block as stated in the Forum Guidelines .
import wixData from ‘wix-data’ ;
import {memory} from ‘wix-storage’ ;
$w.onReady( function () {
memory.clear();
});
let debounceTimer
export function pubSearchBar_input(event) {
if (debounceTimer)
clearTimeout (debounceTimer);
debounceTimer = undefined
debounceTimer = setTimeout(() => {($w( “#pubSearchBar” ).value);}, 350 );
if ($w( “#pubSearchBar” ).value.length >= 3 )
$w( “#infoBox” ).collapse();
if ($w( “#pubSearchBar” ).value.length <= 1 )
$w( “#infoBox” ).expand();
if ($w( “#pubSearchBar” ).value.length >= 3 )
wixData.query( ‘Main’ )
.contains( ‘displayName’ , $w( ‘#pubSearchBar’ ).value)
.or(wixData.query().contains( ‘healthAllergiesSpecialNeeds’ , $w( ‘#pubSearchBar’ ).value))
.or(wixData.query().contains( ‘eMailAddress’ , $w( ‘#pubSearchBar’ ).value))
.or(wixData.query().contains( ‘streetAddress’ , $w( ‘#pubSearchBar’ ).value))
.limit( 12 )
.find()
.then(res => {
$w( “#repeater” ).data = res.items;
$w( “#repeater” ).expand();
if ($w( “#pubSearchBar” ).value.length <= 3 )
$w( “#repeater” ).collapse();
}
)}
Clearing memory is not the same as clearing the search bar. You aren’t even using memory, so there’s nothing to clear.
To clear the search bar, you need to set #pubSearchBar to a blank value. In addition, you then should clear the query filter and run the query without a filter in order to display unfiltered results.
BTW - since you are using the onInput() event for #pubSearchBar, you don’t need to use debounce.
Thank you I will try that and update on the results.