Hello guys, please how do I open a dynamic page in a new tab in wix code
Untested. However,
I wonder if you use a text element with a dynamic .html
Within the repeater itemReady utilise a text element, (#text1)
let URL = itemData.url
let Label = itemData.title
$item(“#text1”).html = <a href=“${URL}” target=“_blank”>${Label}</a>
I don’t think there is a native way to do so.
If you have a button inside a repeater you can set the link of all the items under the dataset ready function like this:
export function dataset1_ready() {
$w("#repeater1").onItemReady( ($item, itemData, index) => {
$w("#repeater1").forEachItem( () => {
$item("#myButton").link = `https://www.mysite.com/page/${$item("#dynamicpage").text}`; //button
});
});
}
then have an onClick for the button:
export function myButton_click(event) {
let $item = $w.at(event.context);
$item("#myButton").target = "_blank";
}
If you don’t have a repeater then use the page’s onReady function to set the link
Thanks a lot