I am a new coder, but gradually learning...so would appreciate a little help here, as I can't figure out the answer from the Velo reference.
I am pulling a random record from my dataset to display in a section...based upon code from another thread I found on here. I have got this working for a couple of elements in my dataset - a regular text field and a rich text field...and it works perfectly for the first of those but only partially for the second. However, I am also trying to display an image from the data set and a button connected to a URL field. What I have is the following today:
$w.onReady( () => {
$w("#RandomMemberOrg").onReady( () => {
let count = $w("#RandomMemberOrg").getTotalCount();
$w("#RandomMemberOrg").getItems(Math.floor(Math.random() * (count - 1)), 1)
.then( (result) => {
let item = result.items[0];
$w("#membertext").html = item.description
$w("#membername").text = item.title
$w("#logo").image = item.logo
})
})
})
So I have three (hopefully pretty simple) questions:
The rich text field is not picking up the theme info from the rich text entry in the dataset...is there some other property type beside .html that I should be utilising?
The use of .image for the image doesn't appear to work....what should I actually be doing here? - SOLVED
How do I connect a new link to a button in a similar fashion? - SOLVED
Thanks,
Simon.
First answer would be to use the CSS code inside the text like this:
$w("#membertext").html = `<span style="color: blue">${item.description}<span>`
The second answer would be to use the .src link on the dataset like this:
$w("#logo").src = item.src
The third would be using the .link method in the Button itself:
$w("#myButton").link = "http://www.wix.com"
1) The rich text field is not picking up the theme info from the rich text entry in the dataset...is there some other property type beside .html that I should be utilising?
Perhaps you need this ...
https://www.wix.com/velo/reference/$w/richtextbox/value
2) The use of .image for the image doesn't appear to work....what should I actually be doing here? let imageSource = $w("#myImage").src; "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=112
3) How do I connect a new link to a button in a similar fashion? $w("#myElement").link = "http://wix.com"; $w("#myElement").target = "_blank";