Memory.clear() not working on live site, preview mode works fine

Hi,

I have a dataset in a table with filters, each row leads to a dynamic page. On each dynamic page I have a button who goes back to the table filtered before, to accomplish that I use memory.setItem for each dropdown value. This works fine. Now I have a button who clears all filters to start a new search, so I use memory.clear() to empty the stored values for the filters. But somehow clicking on the reset button, the items stored still get set as the placeholder text even though the table is not filtered. Which causes side effects if a new search is done.

I’ve tried several ways to do this but none seem to work. My site is www.segamacusers.com and this is the code for the reset button:

export function StateClr_click(event) {
memory.clear()

memory.setItem("Model",  **null** ) 
memory.setItem("Trans",  **null** ) 
memory.setItem("Year",  **null** ) 
memory.setItem("Location",  **null** ) 
memory.setItem("Taller",  **null** ) 
memory.setItem("State",  **null** ) 
memory.setItem("Status",  **null** ) 

function count() {
let total = $w(‘#Disponibilidad’).getTotalCount();
if (total > 0) {
$w(‘#text84’).text = total.toString();
} else {
$w(‘#text84’).text = “No result found.”;
}
}

$w('#Disponibilidad').onReady(() => { 
    $w('#Disponibilidad').setFilter(wixData.filter().isNotEmpty("numMach")) 
        .then(count); 
    UniqueDropDownStateAll() 
    UniqueDropDownWorkshopAll() 
    UniqueDropDownModelAll() 
    UniqueDropDownTransmAll() 
    UniqueDropDownYearAll() 
    UniqueDropDownLocAll() 
    UniqueDropDownStatusAll() 
    $w('#Statedropdown').value =  **null** 
    $w('#Statedropdown').selectedIndex =  **null** ; 
    $w("#ModDropdown").value =  **null** 
    $w("#ModDropdown").selectedIndex =  **null** 
    $w('#TransDropdown').value =  **null** 
    $w('#TransDropdown').selectedIndex =  **null** 
    $w('#LocationDropdown').value =  **null** 
    $w('#LocationDropdown').selectedIndex =  **null** 
    $w('#StatusDropdown').value =  **null** 
    $w('#StatusDropdown').selectedIndex =  **null** 
    $w('#TallerDropdown').value =  **null** 
    $w('#TallerDropdown').selectedIndex =  **null** 
    $w('#YearDropdown').value =  **null** 
    $w('#YearDropdown').selectedIndex =  **null** 
    console.log($w('#Statedropdown').value) 
    console.log($w('#ModDropdown').value) 
    console.log($w('#TransDropdown').value) 
    console.log($w('#LocationDropdown').value) 
    console.log($w('#StatusDropdown').value) 
    console.log($w('#TallerDropdown').value) 
    console.log($w('#YearDropdown').value) 
}) 

Thanks in advance!

First of all, the onReady() event handler for the dataset is only needed when you need to perform some actions right after the dataset is ready. It’s incorrect to use it in a button (or other) event handler).

Since you are using memory.clear(), you don’t need to set all of the memory items to null .

To reset your dataset filter, you also need to clear the dataset’s filter like this:

$w("#Disponibilidad").setFilter( wixData.filter() );

Thanks @yisrael-wix for the quick reply!

The onReady() handler and setting the memory items to null were all attempts to solve the issue. But after I reset the filters with the button and next do a new search it somehow takes into account also the previous filters, that is why I think the memory did not get cleared, or something similar. (I don’t know :frowning: )

I’ve made a video of the sequence, would it be possible for me to send this to you?

Thanks!

@laurensvandamme Did you clear the filter as I showed in my previous post?

$w(" #Disponibilidad ").setFilter( wixData.filter() );

@yisrael-wix I used $w(“#Disponibilidad”).setFilter( wixData.filter() );
because $w(“#Disponibilidad#Disponibilidad”).setFilter( wixData.filter() ); gives me an error:

@laurensvandamme There’s apparently a problem with the forum’s display of component IDs. The correct line of code just has one Disponibilidad with a hashtag prefix.

For the then(), delete the semicolon at the end of the line.

@yisrael-wix , this is the code for the reset button now:

Everything works just fine until I press the reset button and perform a new search:

  1. I perform the search


2. I go to another page


3. I go back to the table I filtered, which is shown thus so far all ok

  1. I reset filters to start new search, ok.


5. Start new search with just the Model filter filled in, and I get this:


When I do exactly the same steps but in step 2 I do not change my page, so nothing in the memory is used, step 5 works perfectly. Also in the preview mode this works fine.

Any thoughts?
Thanks!

Hi @yisrael-wix , by any chance did you have some time to have a look at this? I hope I explained the issues well enough. Thanks!

@laurensvandamme Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.

@yisrael-wix https://www.segamacusers.com/pricing
It’s on the page called Pricing.

Thanks in advance for your tiime!