So I am trying to implement the following:
I have a search button in the header of every page. Once it is clicked a lightbox shows up and when you type in a query it takes you to a page with results
so I have a code in in the “site” section calling for lightbox:
import wixWindow from "wix-window";
export function searchIcon_click(event) {
wixWindow.openLightbox('SearchLightBox')
.then( (searchData) => {
let receivedData = searchData;
} );
}
“searchData” represents whatever the user types in the search field
then the lightbox “page” code section i have the following code:
import wixLocation from 'wix-location';
import wixWindow from "wix-window";
$w.onReady(function () {
let searchData = wixWindow.lightbox.getContext();
$w("#searchBar").value = searchData;
});
export function searchBar_keyPress(event, $w) {
if (event.key === "Enter") {
wixWindow.lightbox.close( {
});
wixLocation.to("/searchresults");
}
}
then I have the “searchresults” page code (resultsTable is collapsed on load)
import wixData from "wix-data";
import wixLocation from 'wix-location';
import wixWindow from "wix-window";
$w.onReady(function () {
$w("#resultsTable").columns = [{
"id": "col1",
"dataPath": "image",
"label": "image",
"width": 180,
"type": "image",
"linkPath": "link-image-info-category-number"
},
{
"id": "col2",
"dataPath": "title",
"label": "title",
"width": 290,
"visible": true,
"type": "string",
"linkPath": "link-image-info-category-number"
},
{
"id": "col3",
"dataPath": "description",
"label": "description",
"width": 500,
"visible": true,
"type": "string",
"linkPath": "link-image-info-category-number"
},
{
"id": "col4",
"dataPath": "location",
"label": "location",
"width": 1,
"visible": false,
"type": "string",
"linkPath": "link-image-info-category-number"
},
{
"id": "col5",
"dataPath": "divesite",
"label": "divesite",
"width": 1,
"visible": false,
"type": "string",
"linkPath": "link-image-info-category-number"
}
];
wixData.query("Image-Info")
.contains("title", ("#searchData").value)
.find()
.then(res => {
$w("#resultsTable").rows = res.items;
});
wixData.query("Image-Info")
.contains("description", ("#searchData").value)
.find()
.then(res => {
$w("#resultsTable").rows = res.items;
});
wixData.query("Image-Info")
.contains("location", ("#searchData").value)
.find()
.then(res => {
$w("#resultsTable").rows = res.items;
});
wixData.query("Image-Info")
.contains("divesite", ("#searchData").value)
.find()
.then(res => {
$w("#resultsTable").rows = res.items;
});
$w("#resultsTable").expand();
});
the result is:
- I don’t get any search results and I believe that I am missing some code, but I cant’t figure out how to fix it - I have been roaming the forums for last 6 hours.
- if I calling the searchLightBox and I am already on the search results page, it doesn’t work at all - meaning typing in a query and pressing enter does not close the LightBox and reload the search results.
I implore someone to help with a detailed solution - I have looked at the API reference and I can’t figure out how the data is passed from lightbox to the page in a way that I can use it…
PLEASE HELP ME!!!