top of page
19 Restaurants
Chicken Makhani

Chicken Makhani

Indian

Caprese Salad with Pesto Sauce

Caprese Salad with Pesto Sauce

Italian

Bruschetta

Bruschetta

Italian

Cassoulet

Cassoulet

French

Panzenella

Panzenella

Italian

Coq au vin

Coq au vin

French

import wixData from 'wix-data';

 

let debounceTimer;

 

$w.onReady(() => {

 

    $w("#searchInputID").onKeyPress(function () {

 

        $w("#xIconID").show();

 

        $w("#searchInputID").value;

 

        if (debounceTimer) {

            clearTimeout(debounceTimer);

            debounceTimer = undefined;

        }

        debounceTimer = setTimeout(() => {

            filter($w("#searchInputID").value);

        }, 200);

 

    })

 

    let searchWord;

 

    function filter(search) {

        if (searchWord !== search) {

            $w("#datasetID").setFilter(wixData.filter().contains('fieldkey1', search)

                    .or(wixData.filter().contains("fieldkey2", search))

                    //Insert more field filter here ====> here <====

                )

 

                .then(countItems)

            searchWord = search

 

        }

 

    }

 

    //COUNT SEARCH FUNCTION 🚀

    function countItems() {

        let count = $w("#datasetID").getTotalCount()

        count > 0 ? $w("#countTextID").text = `${count} Restaurants` : $w("#countTextID").text = `No Restaurants Found 😥`;

 

        return countItems;

    }

 

    //LOAD COUNT WHEN DATASET IS READY 🎉

    $w("#datasetID").onReady(function () {

        countItems();

    });

 

    // CLEAR SEARCH CODE 🎉

    $w('#xIconID').onClick(() => {

 

        $w("#searchInputID").value = undefined

        $w("#datasetID").setFilter(wixData.filter()).then(countItems())

 

        $w("#xIconID").hide();

 

    })

})

Copied!

bottom of page