Hello,
Thanks a lot for the initiative, this is a great idea ! ![]()
So, here’s the thing : I am trying to call different items of my database in order to have one dynamic page in French and in Spanish displaying different descriptions. The code works fine as it indeed calls two different descriptions for text1, but I have 4 rows in my dataset and on the 4 pages, only the text of the last row appears. Can’t get around the reason why…
Any help would be highly appreciated !
Thank you in advance !
Here’s the code :
import wixData from 'wix-data';
import wixWindow from 'wix-window';
$w.onReady(function () {
$w("#dynamicDataset").onReady( () => {
console.log("the dataset is ready");
update_items();
let itemObj = $w("#dynamicDataset").getCurrentItem();
$w("#dynamicDataset").onCurrentIndexChanged( (index) => {
console.log("the item changed");
update_items();
});
});
function update_items () {
const current_item = $w("#dynamicDataset").getCurrentItemIndex();
let language = wixWindow.multilingual.currentLanguage;
let description_text;
console.log(current_item);
wixData.query("PRODUITS").find().
then( (results) => {
if(language === "es"){
description_text = results.items[current_item].description_es;
} else if (language === "fr") {
description_text = results.items[current_item].description_fr;
} else {
description_text = results.items[current_item].description_fr;
}
$w("#text1").text = description_text;
});
}
});