Code to reset search/filter results doesn't work, please help

Question:
What’s wrong with my code? The search/filtering function works fine when I press the search button, but I have the reset button layered right on top of the search button and it’s supposed to appear after the display of the search results. This works fine, but when I press the reset button, which is supposed to reset the page to its original form, nothing happens.

Here’s the code (I tried using chatgpt and claude for help but nothing worked, and this is pretty much my first time using code):


import wixData from 'wix-data';
$w('#resetButton').hide();
let originalDataset = null;

$w.onReady(function () {
    // Any additional setup can be added here.
});

export function searchButton_click(event) {
    search();
}

function search() {
    wixData.query("NewsUpdates")
        .contains("headline", $w('#input5').value)
        .or(wixData.query("NewsUpdates")
            .contains("content", $w('#input5').value))
        .find()
        .then(results => {
            $w('#repeater1').data = results.items;
            $w('#resetButton').show();
            $w('#resetButton').enable();
            $w('#searchButton').hide();
            originalDataset = results.items;
        })
        .catch((error) => {
            console.log(error);
        });
}

export function resetButton_click(event) {
    $w('#repeater1').data = originalDataset;
    $w('#input5').value = "";
    $w('#searchButton').show();
    $w('#searchButton').enable();
    $w('#resetButton').hide();
}

Hi, Project_Management!

First, $w('#resetButton').hide(); needs to be placed inside onReady (or you need to select $w('#resetButton') in the editor and set its default value to “hidden” in the properties). Next, regarding the issue where pressing the reset button does not reset the results, you might need to reset $w('#repeater1').data with an empty value like [] (or with your default item for the repeater). Also, when using repeaters, using repeater-related methods such as onItemReady can often help with proper operation.

https://dev.wix.com/docs/velo/api-reference/$w/repeater/on-item-ready