I am currently working on a project where I am using a code to load additional data to blogs/posts stored on a created data collection. I am now facing an issue with displaying the data stored on the rich content field through the rich content element. I would appreciate your guidance in identifying the property that I should use with the rich content element to achieve this.
I would be grateful if you could provide me with your expert advice on this matter.
Below is the code I am using now, the problem on the last line
import wixData from 'wix-data';
import wixLocation from 'wix-location';
let currentPost;
$w.onReady(async function () {
const postData = await $w('#dynamicDataset').getCurrentItem();
currentPost = await loadExtraPostData(postData);
assignPostDataToUIElements();
});
let currentPost;
$w.onReady(async function () {
const postData = await $w('#dynamicDataset').getCurrentItem();
currentPost = await loadExtraPostData(postData);
assignPostDataToUIElements();
});
async function loadExtraPostData(postData) {
const postDataFromCollection = await wixData.query('PostExtraData')
.eq('post', postData._id)
.find();
const extraData = postDataFromCollection.items[0];
return mergePostData(postData, extraData);
}
function mergePostData(post, extraData) {
return Object.assign({}, post, extraData);
}
function assignPostDataToUIElements() {
$w('#shortDescription').text = currentPost.shortDescription;
//adv1
$w('#adv1Image').src = currentPost.adv1Img;
$w('#adv1Title').text = currentPost.adv1Title;
$w('#adv1Text').text = currentPost.adv1Text;
//adv2
$w('#adv2Image').src = currentPost.adv2Img;
$w('#adv2Title').text = currentPost.adv2Title;
$w('#adv2Text').text = currentPost.adv2Text;
//adv3
$w('#adv3Image').src = currentPost.adv3Img;
$w('#adv3Title').text = currentPost.adv3Title;
$w('#adv3Text').text = currentPost.adv3Text;
//try
$w('#richContentAdv1').postData = currentPost.adv1;
}