# Direct repeater item to dynamic page

**URL:** <https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [September 3, 2018, 10:09am UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981 "2018-09-03T10:09:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![postsite](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@postsite](https://forum.wixstudio.com/u/postsite)\
**Post date:** [September 3, 2018, 10:09am UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/1 "2018-09-03T10:09:52Z")

</div>

i want users to click on one item in repeater page and then direct them to a dynamic page and show data of selected item at that place,  
may you help me?🙂 please help if you know very greatfull if i know it  
thanks

---

<div class="post-metadata">

**Author:** ![mhammouz](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mhammouz/32/4033_2.png) [@mhammouz](https://forum.wixstudio.com/u/mhammouz)\
**Post date:** [September 3, 2018, 11:24am UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/2 "2018-09-03T11:24:04Z")

</div>

Hi,

First you need to get the current Item onClick, then to use these data to redirect the page to that item’s dynamic page. So your code should look something like this :

```javascript
   $w("#ItemContainer").onClick( (event, $w) => {
 let targetId = $w("#dataset1").getCurrentItem()._id;
  wixLocation.to('/dynamicPage/'+ targetId) // 
} );

```

Note that i used the id to be the page Title ( Path ) .

Hope this helps!  
Best,

Mustafa

---

<div class="post-metadata">

**Author:** ![postsite](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@postsite](https://forum.wixstudio.com/u/postsite)\
**Post date:** [September 3, 2018, 12:48pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/3 "2018-09-03T12:48:02Z")

</div>

thanks, i’m so happy 😉

---

<div class="post-metadata">

**Author:** ![jessica22003](https://avatars.discourse-cdn.com/v4/letter/j/c4cdca/32.png) [@jessica22003](https://forum.wixstudio.com/u/jessica22003)\
**Post date:** [April 20, 2019, 5:00pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/4 "2019-04-20T17:00:42Z")

</div>

Hello,

@mhammouz I have the same issue, but have no idea how to code it to get it to work… can you help me please? My website is [www.maidstonelabour.com](http://www.maidstonelabour.com), and the repeater page is from the Menu: Key People: Councillors & Candidates ([www.maidstonelabour.com/2019-council-candidates](http://www.maidstonelabour.com/2019-council-candidates)) I’d like to be able to click on the image in each repeater and for the user to be taken to the dynamic page that corresponds to that person’s biography page, which is located in the dataset connected in that page…

Cheers,

Jessica

---

<div class="post-metadata">

**Author:** ![emilyrohlfs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emilyrohlfs/32/14197_2.png) [@emilyrohlfs](https://forum.wixstudio.com/u/emilyrohlfs)\
**Post date:** [August 26, 2019, 9:43pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/5 "2019-08-26T21:43:03Z")

</div>

Hello! I am trying to do the same thing. My repeater has the words “Read More” and no pre-programmed way to link it to the dynamic page. Only the images link to the dynamic page.

I copied and pasted Mustafa’s example above.

The only thing I changed was “#ItemContainer” to “#text47” (button name). Is that correct?

It’s not working. The only error appears to be: “wixLocation” is “undefined.”

Am I supposed to change wixLocation to the Field Key? How do I point to the page?

![](https://us1.discourse-cdn.com/wix/original/3X/7/1/718fe0acf8fbecf6f612c8742dafb4c80f3135d0.jpeg)

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [August 26, 2019, 9:45pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/6 "2019-08-26T21:45:33Z")

</div>

Do not use wixLocation.to.to  
Omit one of the “.to”

---

<div class="post-metadata">

**Author:** ![emilyrohlfs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emilyrohlfs/32/14197_2.png) [@emilyrohlfs](https://forum.wixstudio.com/u/emilyrohlfs)\
**Post date:** [August 26, 2019, 9:59pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/7 "2019-08-26T21:59:36Z")

</div>

Points for speed! But … it didn’t work ☹

$w(“#text47”).onClick( (event, $w) =\> {  
**let** targetId = $w(“#dataset1”).getCurrentItem().\_id;  
wixLocation.to(‘/dynamicPage/’+ targetId) //  
} );

---

<div class="post-metadata">

**Author:** ![emilyrohlfs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emilyrohlfs/32/14197_2.png) [@emilyrohlfs](https://forum.wixstudio.com/u/emilyrohlfs)\
**Post date:** [August 26, 2019, 10:03pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/8 "2019-08-26T22:03:47Z")

</div>

Is the last “targetId” supposed to be the button # also?

Sorry - I took web design classes almost 20 years ago ☹

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [August 26, 2019, 10:05pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/9 "2019-08-26T22:05:58Z")

</div>

You probably has to change the \_id and use the field key with the link to your target page.  
for example:

```javascript
let targetId = $w("#dataset1").getCurrentItem()["link-title"];
wixLocation.to(targetId);
//check your collection to see the field key. Be sure to use the field key and not the field name.

```

---

<div class="post-metadata">

**Author:** ![emilyrohlfs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emilyrohlfs/32/14197_2.png) [@emilyrohlfs](https://forum.wixstudio.com/u/emilyrohlfs)\
**Post date:** [August 26, 2019, 10:11pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/10 "2019-08-26T22:11:18Z")

</div>

Well, that didn’t do it, but I’m out of time today. I’ll try again tomorrow - thank you!

---

<div class="post-metadata">

**Author:** ![emilyrohlfs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emilyrohlfs/32/14197_2.png) [@emilyrohlfs](https://forum.wixstudio.com/u/emilyrohlfs)\
**Post date:** [August 27, 2019, 7:35pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/11 "2019-08-27T19:35:36Z")

</div>

Thoroughly confused.

After J.D.'s post I tried a few things. The latest:

$w(“#text47”).onClick( (event, $w) =\> {  
**let** targetID = $w(“#dataset1”).getCurrentItem()[“link-mobilestorytimekit-Kit-Info-title”];  
wixLocation.to(‘/dynamicPage/’+ targetID) //  
} );

I still don’t know if I’m supposed to change “wixLocation” and what I’m supposed to type in its place.  
And targetID - that’s another one I’m not sure of.  
#item container is the name of the button “Read More”  
I changed “link-title” to my field key

Is there a spelling error? Something else I’m missing?  
Am I supposed to do something on the dynamic page side?

Why is there a “Read More” button on this repeater Wix? Wix tech support will not help me - they sent me here instead.

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [August 27, 2019, 7:42pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/12 "2019-08-27T19:42:04Z")

</div>

delete this: ’ **/dynamicPage/'+**  
Use:

```javascript
wixLocation.to(targetID);

```

---

<div class="post-metadata">

**Author:** ![emilyrohlfs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emilyrohlfs/32/14197_2.png) [@emilyrohlfs](https://forum.wixstudio.com/u/emilyrohlfs)\
**Post date:** [August 27, 2019, 9:13pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/13 "2019-08-27T21:13:39Z")

</div>

Like this:

$w(“#text47”).onClick( (event, $w) =\> {  
**let** targetID = $w(“#dataset1”).getCurrentItem()[“link-mobilestorytimekit-Kit-Info-title”];  
wixLocation.to(‘wixLocation.to(targetID);’+ targetID) //  
} );

That didn’t work either ☹  
And there were these errors:

There was an error in your script  
The element selector function (usually $w) cannot be used before the page is ready

I successfully coded the next and previous buttons on the dynamic page, so this is everything on that page, if that makes a difference (?):

**import** {local} **from** ‘wix-storage’;

**const** linkField = “link-mobilestorytimekit-Kit-Info-title”; // replace this value

$w.onReady( **function** () {  
$w(“#dataset1”).onReady(() =\> {  
**const** numberOfItems = $w(“#dataset1”).getTotalCount();

```
$w("#dataset1").getItems(0, numberOfItems) 
  .then( (result) => {  

```

**const** dynamicPageURLs = result.items.map(item =\> item[linkField]);  
local.setItem(‘dynamicPageURLs’, dynamicPageURLs);  
} )  
. **catch** ( (err) =\> {  
console.log(err.code, err.message);  
} );  
} );  
} );

$w(“#text47”).onClick( (event, $w) =\> {  
**let** targetID = $w(“#dataset1”).getCurrentItem()[“link-mobilestorytimekit-Kit-Info-title”];  
wixLocation.to(‘wixLocation.to(targetID);’+ targetID) //  
} );

---

<div class="post-metadata">

**Author:** ![emilyrohlfs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emilyrohlfs/32/14197_2.png) [@emilyrohlfs](https://forum.wixstudio.com/u/emilyrohlfs)\
**Post date:** [August 27, 2019, 9:18pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/14 "2019-08-27T21:18:13Z")

</div>

I thought that maybe I misunderstood, so I changed to this, but still no dice:

**import** {local} **from** ‘wix-storage’;

**const** linkField = “link-mobilestorytimekit-Kit-Info-title”; // replace this value

$w.onReady( **function** () {  
$w(“#dataset1”).onReady(() =\> {  
**const** numberOfItems = $w(“#dataset1”).getTotalCount();

```
$w("#dataset1").getItems(0, numberOfItems) 
  .then( (result) => {  

```

**const** dynamicPageURLs = result.items.map(item =\> item[linkField]);  
local.setItem(‘dynamicPageURLs’, dynamicPageURLs);  
} )  
. **catch** ( (err) =\> {  
console.log(err.code, err.message);  
} );  
} );  
} );

$w(“#text47”).onClick( (event, $w) =\> {  
**let** targetID = $w(“#dataset1”).getCurrentItem()[“link-mobilestorytimekit-Kit-Info-title”];  
‘wixLocation.to(targetID);’ //  
} );

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [August 27, 2019, 9:41pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/15 "2019-08-27T21:41:10Z")

</div>

First of all, you need of course to import wixLocation from ‘wix-location’;  
Second, I’m not sure what kind of page is it. On one hand you counted the numberOfItems which means there’re many items in the dataset. On the other hand, you used .getCurrentItem() that can get a single item. So you should elaborate a little bit more and explain what you’re trying to achieve.

---

<div class="post-metadata">

**Author:** ![emilyrohlfs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emilyrohlfs/32/14197_2.png) [@emilyrohlfs](https://forum.wixstudio.com/u/emilyrohlfs)\
**Post date:** [August 27, 2019, 9:54pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/16 "2019-08-27T21:54:40Z")

</div>

So sorry! And I’ve been googling wixLocation and nothing tells me what this means. I’m supposed to import something?

I have a dataset with multiple Story Time kits, with: kit name, image, short description, and long description. We have about 14 of these kits right now.  
I have a page with a repeater that has the list of kits, names, and short descriptions.  
When you click an image on the repeater it opens a dynamic page with the name, a larger image, short description, and a long description. Only the image will link to a dynamic page with the usual Wix tools.

I asked Wix how to make a next and previous button on the dynamic page for each kit, and they sent me a bunch of links. I tried everything until those buttons worked. I also asked Wix how to make this link I’m trying to make now, but they didn’t understand the question when I referred to it as “Read More.”

Visual aid:  
[https://www.keokuklibrary.org/mobile-story-time](https://www.keokuklibrary.org/mobile-story-time)

I really do appreciate you trying to help.

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [August 27, 2019, 10:12pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/17 "2019-08-27T22:12:07Z")

</div>

Now I got you.  
So at top of the page code, you should write:

```javascript
import wixLocation from 'wix-location';

```

Since text47 is inside a repeater, you can’t treat it as a regular item, and instead of your onClick() function, you should use this code:

```javascript
$w("#repeater1").onItemReady( ($item, itemData, index) => {
 $item("#text47").onClick( (event) => {
 wixLocation.to(itemData["link-mobilestorytimekit-Kit-Info-title"]);
 }); 
})

```

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [August 27, 2019, 10:20pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/18 "2019-08-27T22:20:32Z")

</div>

and put the $w(“#repeater1”).onItemReady() function inside the $w.onItemReady().

---

<div class="post-metadata">

**Author:** ![emilyrohlfs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/emilyrohlfs/32/14197_2.png) [@emilyrohlfs](https://forum.wixstudio.com/u/emilyrohlfs)\
**Post date:** [August 28, 2019, 2:59pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/19 "2019-08-28T14:59:30Z")

</div>

I’m sure I mangled your instructions! Can you tell me what’s wrong with this picture?

**import** wixLocation **from** ‘wix-location’;  
**import** {local} **from** ‘wix-storage’;

**const** linkField = “link-mobilestorytimekit-Kit-Info-title”; // replace this value

$w.onReady( **function** () {  
$w(“#dataset1”).onReady(() =\> {  
**const** numberOfItems = $w(“#dataset1”).getTotalCount();

```
$w("#repeater1").onItemReady( ($item, itemData, index) => { 

```

$item(“#text47”).onClick( (event) =\> {  
wixLocation.to(itemData[“link-mobilestorytimekit-Kit-Info-title”]);

```
$w("#dataset1").getItems(0, numberOfItems) 
  .then( (result) => {  

```

**const** dynamicPageURLs = result.items.map(item =\> item[linkField]);  
local.setItem(‘dynamicPageURLs’, dynamicPageURLs);  
} )  
. **catch** ( (err) =\> {  
console.log(err.code, err.message);  
} );  
} );  
})

It doesn’t like the punctuation at the end, that’s for sure.

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [August 28, 2019, 3:35pm UTC](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981/20 "2019-08-28T15:35:01Z")

</div>

add **})})** after this line: wixLocation.to(itemData[“link-mobilestorytimekit-Kit-Info-title”]);

[Next page](https://forum.wixstudio.com/t/direct-repeater-item-to-dynamic-page/9981.md?page=2)
