Lets say I have these elements on my wix page with the given ID's
"links"
"contactus"
"shortDec"
I have in incoming json string with
{
"pageElements": {
"links": "<a>1</a><a>2</a>",
"contactus": "mailto:jaberfish@yahoo.com",
"shortDec": "Contact us to give us a ring!",
}
}
What I need to do is loop through pageElements and apply them to the page ID's html
How would I do this with wix?
Fiddled and works!
$w.onReady(function () {
let steamIDJSON = resolveVanityUsername()
.then((steamIDJSON) => {
console.log(steamIDJSON.response);
// $w("#result").html=steamIDJSON.steamid
$w('Text').forEach(function(c){
c.html=steamIDJSON.response[c.id];//steamIDJSON.fos;
});
});
Also, the elements that I have on the wix page varies dependent on the loaded page. Some may have more elements then just three with different names. Thats why I think a loop is best. But I figure, the easiest way to link up whats in the json file is to have the same IDs.
What I have is, but need to loop through elements instead of defining each one
$w.onReady(function () {
let steamIDJSON = resolveVanityUsername()
.then((steamIDJSON) => {
console.log("Response JSON: " + steamIDJSON.steamid);
$w("#links").html=steamIDJSON.links
$w("#contactus").html=steamIDJSON.links
$w("#shortDec").html=steamIDJSON.links
});
})