Background: Text box displays Country, State etc from Google Location object field in collection. The following code works for a collapsible text box, in a repeater, on a Dynamic List page.
Question: How do I modify the code to work in a regular text box, just on a Dynamic Item page? (no repeater)
import wixData from 'wix-data';
/////////// [USER-INTERFACE] //////////////
const DATASET = "listingsDataset";
const DATABASE = "Properties";
const REPEATER = "propertiesRepeater";
const FIELD = "mapLocation";
/////////// [USER-INTERFACE] //////////////
$w.onReady(()=> {console.log('PAGE-READY...');
$w(`#${DATASET}`).onReady(async()=>{console.log('DATASET READY...');
const myDataQuery = await wixData.query(DATABASE).find(); console.log('myDataQuery: ', myDataQuery);
// REPEATER-PART...
$w(`#${REPEATER}`).onItemReady(($item, itemData, index) => {console.log('Item-Data: ', itemData);
if(itemData) {console.log('Item-Data found!');
if (itemData[FIELD]) { console.log('Location-Property found!');
const mapLocation = itemData[FIELD];
const city = mapLocation.city;
const state = mapLocation.subdivision;
const country = mapLocation.country;
$item('#collapsibleText2').text = `${city}, ${state}, ${country}`;
} else {console.log('Location-Property NOT found!');}
} else {console.log('Item-Data is not defined or null...');}
});
});
});
I’m aware of substituting the dataset, but clueless about the rest
Thank you!