Hey brains trust, i’m in need of a little help.
My website uses has a database of names and details and has a search function allowing members to search the database by name. When i’m editing the site and click “preview” the search function works perfectly and the data is displayed in the table as it is meant to. However, when i press “publish” and try to use the same function on the published page, it doesn’t work. Nothing is displayed in the table.
Any help you can provide will be very much appreciated.
The sites live address is https://badtennants.wixsite.com/website
The code for the page is below. You’ll notice that there are a number of lines where i’ve previously tried to modify the search so that it searches for multiple attributes at the same time but i couldn’t get it to work so i’ve removed those lines with // so they shouldn’t be a problem.
import wixData from “wix-data”;
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
//TODO: write your page related code here…
export function searchbutton_click(event) {
//Add your code for this event here:
// Runs a query on the “recipes” collection
wixData.query(“Tenant_Blacklist”)
// let Searchquery = wixData.query(“Tenant_Blacklist”)
// Query the collection for any items whose “Name” field contains
// the value the user entered in the input element
.contains(“tenantFullName”, $w(“#input7”).value)
// .eq(“DateOf Birth”, $w[“#textbox1”])
// The next 2 lines are my attempt at searching multiple attributes within the database at the same time.
// .eq(“DOB”, “#input8”)
// .and(Searchquery).contains(“DOB”,$w(“#textBox1”).value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w(“#table1”).rows = res.items;
});
}
$w.onReady( function () {
$w(“#table1”).columns = [
{
“id”: “col1”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “Country”,
“label”: “Country”, // The column header
“width”: 150, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col2”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “tenantFullName”,
“label”: “Tenant Full Name”, // The column header
“width”: 150, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col3”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “DOB”,
“label”: “Date of Birth”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col4”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “scoreOutOf10”,
“label”: “Score Out Of 10”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col5”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “rentalAddress”,
“label”: “Rented Address”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col6”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “landlordPropertyManagerName”,
“label”: “Property Manager’s Name”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col7”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “landlordPropertyManagerPhoneNumber”,
“label”: “Property Manager Phone”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col8”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “reasonsForReviewScore”,
“label”: “Reviewer Notes”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col9”,
“dataPath”: “photos”,
“label”: “photos”,
“visible”: true ,
“type”: “image”,
“linkPath”: “link-field-or-property”
},
]
// more column objects here if necessary
// …
// …
});