For some reason I can´t get it to work! It´s been driving me nuts... I´ve been trying to get a search bar to work for the past week. My database is called "items1" I´m trying to only search the first field "title" but no go! Wix has both $item, itemData (3rd line and 4th line) underlined in red, saying "cannot find name". Not sure what I´m doing wrong.
I've found a temporary solution of adding the "Table Master" Widget to my Wix page (live site here: https://www.laguaridaderol.es/dnd-5e-lista-de-hechizos ) BUT this is only temporary as I cannot link each row with wix dynamic pages (each individual spell has it's on page).
Ideally, I would need it to work with a table and not a repeater. But I've not found a way to make it work. Would it work as well with a table?
import wixData from 'wix-data';
$w.onReady (function () {
$w("#mockDataRepeater").onItemReady(($item, itemData)) => {
$item("#title").text = itemData.title;
});
async function search(){
const query = $w("#searchQueryInput").value;
const titleQuery = wixData.query("Items1").contains("title", query);
const mockDataQueryResult = await wixData.query("Items1").contains("title", query).find();
const mockData = mockDataQueryResult.items;
$w('#mockDataRepeater').data = mockData;
}
$w("#searchButton").onClick(search)
$w("#searchQueryInput").onInput(() => {
search();
})
});
Hi Desiree,
I took a look at your site and it looks like you have the table up and running! Nonetheless I addressed the code issues you were having in this video: