Hi,
This is my code on search function and i want to add “not found” when the data are not exist.
How is that??
export function searchButton_onClick(event){
wixData.query(‘JobVacancies’)
.contains(‘position’, $w(‘#input1’).value)
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
});
}
1 Like
Hay Koymaks,
Just add an if test to check if the number of results is 0 or more, and show the not found experience.
.then(res => {
if (res.items.length === 0)
// do the not found experience, probably hiding the table and showing something else instead.
else
$w(’ #table1 ').rows = res.items;
});
Hi,
I understand the code you give but how do i code “not found” message in this line…
// do the not found experience, probably hiding the table and showing something else instead.
And also i want when the user search the existing data, the “not found” message will hide.
Hi,
It depends on your site design.
You can for example set a text to always show ‘not found’ and simply hide it when there are results and show it when there are none.