Open Site Navigation

Search Filter in Wix

Learn to filter repeaters with search inputs in Wix.


Search Filter in Wix

Before you insert the code, watch this video to learn how to properly set up your database and content:



Now that you have your site set up, here is the code you will need:

 

import wixData from 'wix-data'; $w('#resetButton').hide(); export function searchButton_click(event) { search(); } function search() { wixData.query("Properties") .contains("title", $w('#searchInput').value) .or(wixData.query("Properties").contains("agentName", $w('#searchInput').value)) .find() .then(results => { $w('#propertiesRepeater').data = results.items; }); $w('#searchButton').hide(); $w('#resetButton').show(); $w('#resetButton').enable(); } export function resetButton_click(event) { $w('#propertiesDataset').setFilter(wixData.filter()); $w('#searchInput').value = undefined; $w('#searchButton').show(); $w('#searchButton').enable(); $w('#resetButton').hide(); }

 

To ensure that the code works properly, make sure you set the names of your elements to match the code OR change the code to match the names of the elements on your site.


Have Fun!