Not able to link repeater to dynamic page.

Hello,

Am trying to link a button in my repeater to a dynamic page using your code, but am getting error and it’s not working.

Following is the code:

$w.onReady(function () {
$w(‘#resultsRepeater’).onItemReady(($w, itemData, index) => {
$w(“#titleElement”).text = itemData.title;
$w(“#courtElement”).text = itemData.court;
$w(“#dateElement”).text = itemData.date;
$w(“#citationElement”).text = itemData.citation;
$w(“#heldElement”).text = itemData.held;
$w(“#IDElement”).text = itemData._id;
$w(“#documentElement”).link = itemData.document;
// Currently added code from here (NOT WORKING)
let linkToDisplayPage = dataItem[“link-references-_id-referrence-title”];
$w(“#displayElement”).onClick(() = {
wixLocation.to(linkToDisplayPage)
});
// Till here
const hasDoc = itemData.document;
if (hasDoc) {
$w(“#documentElement”).label = ‘Download Judgment’;
$w(“#documentElement”).enable();
$w(“#displayElement”).enable();
} else {
$w(“#documentElement”).label = ‘Judgment & details to be updated soon’;
$w(“#documentElement”).disable();
$w(“#displayElement”).disable();
}
});

Please guide what am doing wrong.

Thanking in anticipation.

Anupam Dubey

Hello Anupam,

Regarding the code you paste, there are some errors you should fix:

  1. Arrow is missing in the onClick function
  $w("#displayElement").onClick(() = {// should be $w("#displayElement").onClick(() => { 
let linkToDisplayPage = dataItem["link-references-_id-referrence-title"]; // itemData instead of dataItem

this should be itemData. And also just in case, be sure that you are taking the right reference.

  1. Be sure that you are importing wixLocation to make the redirecting works .

Hope this helps you.

Good luck.

Mustafa

1 Like

Thanks Mustafa ,

It’s working perfect now.

Thanks again

Anupam Dubey