On a Dynamic page I want to hide a section on the page when a database field contains a specific value. I tried to achieve this with the below code. To be more specific, I want to achieve that if in “Dynamicdataset” field “type” contains value “TRANSPORTATION / FLIGHT”, section 274 is hidden.
The code is not working, could somebody point me in the right direction? I would really appreciate it!
Best regards,
Stefan
import wixUsers from ‘wix-users’ ; import wixLocation from ‘wix-location’ ; import wixData from ‘wix-data’ ; import wixWindow from ‘wix-window’ ;
/**
Adds an event handler that runs when the dataset is ready.
*/
export function dynamicDataset_ready ( ) {
$w ( “#dynamicDataset” ). onReady ( () => { let itemObj = $w ( “#dynamicDataset” ). getCurrentItem (); if ( itemObj . type === “TRANSPORTATION / FLIGHT” ) {
$w ( “#section274” ). hide ();
}
} );
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
import wixWindow from 'wix-window';
$w.onReady(() => {
$w("#dynamicDataset").onReady(() => {
let itemObj = $w("#dynamicDataset").getCurrentItem();
if(itemObj.type === "TRANSPORTATION / FLIGHT") {
$w("#section274").hide();
}
} );
})
make sure the string is exactly RANSPORTATION / FLIGHT with the whitespaces around the slash and nothing more in the beginning and end of the string.
If you wish the string to include this substring but not to be equal to, do:
Would such a code as the one you provided (thanks so much!) also work within a repeater? I have a dynamic page for a travel itinerary that contains a repeater connected database with segments that belong to the itinerary on the dynamic page.
Segments vary from transportation to hotel and each item in the repeater has to show different fields. For example, transportation should show “departure location” and a hotel should show the field “roomtype”. Is it possible to write a code that determines what element is expanded/shown within the repeater item?
I would like to use a similar situation, but in a slideshow repeater. The above code you wrote doesn’t work, do you have an idea on how to get it working?