Reference the following page: https://jds-cvoa.wixsite.com/cvoa/CVOA-Registry
If you click on the Thumbnail image a Lightbox appears with a photo gallery of images stored in CV-Photo-Registry (@dataset2).
I tried using the filter in the Manage Dataset by setting it to match ‘dash’ field key in CVOA-Registry. Using this filtering technique, it always shows the wrong cars as though the filter is not working. I searched and found similar issue Gallery Issues and implemented the Wix Code reference there. Here is my code:
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import {lightbox} from ‘wix-window’;
import wixData from ‘wix-data’;
import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;
$w.onReady( () => {
let regitem = lightbox.getContext();
console.log(“Dash: “, regitem.dash);
$w(”#LByear”).text = regitem.year;
$w(“#LBdash”).text = regitem.dash;
let dash_no = regitem.dash;
console.log(“Filtering Dash Number”, dash_no)
$w(“#dataset2”).setFilter(wixData.filter().contains(‘dash’, dash_no))
. catch ((error) => {
let errorMsg = error.message;
let code = error.code;
});
});
With this code in place I get NO images regardless of which car thumbnail I click?
Please help. Site scheduled to go live Monday… This is the last hurdle…
Thanks
JD
I have tried all kinds of things to get this working… right now… (midnight) it is showing WRONG cars. Each car has one or more photo URLS stored in the CV-Photo-Registry with key of dash. I have reset the page to public so you don’t need a login to view it.
Thanks
JD
Hi cwvega76.
Please try the following:
$w('#dataset2').onReady( () => {
$w("#dataset2").setFilter(wixData.filter().contains('dash', dash_no))
.catch((error) => {
let errorMsg = error.message;
let code = error.code;
});
});
Regards,
Genry.
I assumed this code would go in the onReady main section… Did Not work. Get NO Photos at all. Error shows: Cannot read property of undefined ‘dash’
here is my code as changed:
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import {lightbox} from ‘wix-window’;
import wixData from ‘wix-data’;
import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;
$w.onReady( () => {
let regitem = lightbox.getContext();
console.log(“Dash: “, regitem.dash); <----- this logs the correct dash number…
$w(”#LByear”).text = regitem.year;
$w(“#LBdash”).text = regitem.dash;
let dash_no = regitem.dash
$w(‘#dataset2’).onReady( () => {
$w(“#dataset2”).setFilter(wixData.filter().contains(‘dash’, dash_no))
. catch ((error) => {
let errorMsg = error.message;
let code = error.code;
});
});
});
Hi cwvega76.
Can you please add a semicolon at the end of the following statement?
let dash_no = regitem.dash
Also, can you add a log message in the catch clause for the error?
.catch((error) => {
console.log(JSON.stringify(error));
...
});
Regards,
Genry.
Hmmm… nothing logged except my line 10…
let dash_no = regitem.dash;
$w(‘#dataset2’).onReady( () => {
$w(“#dataset2”).setFilter(wixData.filter().contains(‘dash’, dash_no))
. catch ((error) => {
let errorMsg = error.message;
let code = error.code;
console.log(JSON.stringify(error));
});
});
});
I was just looking back at the CV-Photo_Registry database and noticed that dash field is defined as a reference field in the other database CV-Registryj. I was tying another approach. Maybe that is confusing it?
THAT WAS IT!!! Removed reference fields and it is working as it should! Thanks for the Filter code!
JD