Can anyone please check this code for me? I followed the Wix videos and the one by the Code Queen. On the “Results page” the search is not coming up.
Thank you in advance.
Search page code:
import {local} from ‘wix-storage’;
import wixLocation from ‘wix-location’;
$w.onReady( function () {
});
export function button1_click() {
let word = $w(“#input1”).value;
local.setItem(“searchword”,word);
wixLocation.to(/search
);
}
Results page code:
import { local } from ‘wix-storage’;
import wixData from ‘wix-data’;
$w.onReady( function () {
var sameWord = local.getItem(“searchWord”);
$w(“#input1”).value = sameWord;
$w(“#input1”).placeholder = sameWord;
$w(‘#dataset1’).onReady( function () {
search();
});
});
export function button1_click() {
search();
}
function search(){
wixData.query(‘Food’)
.contains(‘title’, $w(“#input1”).value)
.or(
wixData.query(‘Food’)
.contains(‘type’, $w(“#input1”).value)
)
.or(
wixData.query(‘Food’)
.contains(‘country’, $w(“#input1”).value)
)
.or(
wixData.query(‘Food’)
.contains(‘nationality’, $w(“#input1”).value)
)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w(‘#table1’).rows = res.items;
});
}