I'm trying to create clickable text within a repeater that links to a URL. Because this text is also connected to text in a database, I have to use code to hyperlink it (rich text and transparent buttons aren't options with my website design), but my below code doesn't seem to work. In preview mode, the text appears to be clickable, but doesn't open to a link. This error message appears when I attempt to click it: Wix code SDK error: The url parameter that is passed to the to method cannot be set to the value . It must be of type string.
What am I doing wrong?
import wixLocation from 'wix-location';
$w.onReady(function () {
$w('#repeater5').onItemReady((selector, itemData, index) => {
$w('#Hed1').onClick(() => {
wixLocation.to(itemData.link);
Thanks for this! I realize I forgot to mention I'm trying to create a hyperlink to links in my database--since this is a repeater and the URL differs depending on the text that appears--so, I haven't input a string because there's no one string.
Hello Jessica.
What do you get in conssole, when doind this...
console.log(itemData.link) console.log(typeof itemData.link)
What are the results?
The wixLocation.to"wixLocation.to-command" expects a STRING, like....
wixLocation.to("https://www.google.com");
So perhaps this would work.....
let myLink = (itemData.link).toString() wixLocation.to(myLink);