Hi guys, I’m currently trying to inject content from a database, with ID = BroomhillPark, into a page element called #energyRatingDescription. I’m trying to inject a field called shortDescription, from the BroomhillPark database, to override the filler text with id #energyRatingDescription". So far I’ve written this, which does work, but I’d like to use the current dynamic pages “name” value so the shortDescription of each record is inserted when viewing their specific product page:
import wixData from ‘wix-data’;
$w.onReady( function () {
wixData.query(“BroomhillPark”)
.find()
.then( (results) => {
$w(“#energyRatingDescription”).text = results.items[0].name;
} );
} );
I’ve then set #energyRatingDescription to be hidden on default and I’ve used .show() when a button, #energyRating, is clicked. Each page is advertising a different product so I’d like to display the shortDescription specifically for that product. I feel it will involve using the “this” keyword, or some type of loop, but my knowledge of jquery/corvid isnt amazing.