# getCurrentItem() not giving the correct item from the repeater

**URL:** <https://forum.wixstudio.com/t/getcurrentitem-not-giving-the-correct-item-from-the-repeater/42416>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [May 13, 2022, 6:26pm UTC](https://forum.wixstudio.com/t/getcurrentitem-not-giving-the-correct-item-from-the-repeater/42416 "2022-05-13T18:26:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rebecca10202](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rebecca10202/32/85915_2.png) [@rebecca10202](https://forum.wixstudio.com/u/rebecca10202)\
**Post date:** [May 13, 2022, 6:26pm UTC](https://forum.wixstudio.com/t/getcurrentitem-not-giving-the-correct-item-from-the-repeater/42416/1 "2022-05-13T18:26:46Z")

</div>

I have a dataset connected to a repeater. It isn’t providing the right item with onClick() and getCurrentItem(). It always seems to be giving the first item in the displayed repeater from the dataset. Any ideas why? I have used similar code another website, and it works.

---

<div class="post-metadata">

**Author:** ![roba82587](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roba82587/32/32395_2.png) [@roba82587](https://forum.wixstudio.com/u/roba82587)\
**Post date:** [May 13, 2022, 7:01pm UTC](https://forum.wixstudio.com/t/getcurrentitem-not-giving-the-correct-item-from-the-repeater/42416/2 "2022-05-13T19:01:35Z")

</div>

Hello from the Wix DevRel Team!

I’m not sure why this isn’t working, but the fact that it’s displaying the first item in the repeater makes me think that you’re on the right track. How do you have the onClick() function set up? Can you provide your code here?

Thanks

Rob

---

<div class="post-metadata">

**Author:** ![rebecca10202](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rebecca10202/32/85915_2.png) [@rebecca10202](https://forum.wixstudio.com/u/rebecca10202)\
**Post date:** [May 13, 2022, 7:13pm UTC](https://forum.wixstudio.com/t/getcurrentitem-not-giving-the-correct-item-from-the-repeater/42416/3 "2022-05-13T19:13:40Z")

</div>

It won’t keep the name of my button when I past in the code. But my button name is named in actual code.

![](https://us1.discourse-cdn.com/wix/original/3X/f/7/f700e85d928cc344ba2bec24ddf1343629bdda9d.png)

---

<div class="post-metadata">

**Author:** ![rebecca10202](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rebecca10202/32/85915_2.png) [@rebecca10202](https://forum.wixstudio.com/u/rebecca10202)\
**Post date:** [May 13, 2022, 7:40pm UTC](https://forum.wixstudio.com/t/getcurrentitem-not-giving-the-correct-item-from-the-repeater/42416/4 "2022-05-13T19:40:00Z")

</div>

The above code is what gives me the first record of the repeater.

---

<div class="post-metadata">

**Author:** ![roba82587](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roba82587/32/32395_2.png) [@roba82587](https://forum.wixstudio.com/u/roba82587)\
**Post date:** [May 13, 2022, 7:47pm UTC](https://forum.wixstudio.com/t/getcurrentitem-not-giving-the-correct-item-from-the-repeater/42416/5 "2022-05-13T19:47:07Z")

</div>

The first thing that jumps out at me is that you’re assigning a variable with a $, I would just use `let item = event.context` and then change the other instances of `$item` to just `item`. Does that help anything?

Rob

---

<div class="post-metadata">

**Author:** ![rebecca10202](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rebecca10202/32/85915_2.png) [@rebecca10202](https://forum.wixstudio.com/u/rebecca10202)\
**Post date:** [May 25, 2022, 9:06pm UTC](https://forum.wixstudio.com/t/getcurrentitem-not-giving-the-correct-item-from-the-repeater/42416/6 "2022-05-25T21:06:13Z")

</div>

Thank you, Rob. I was able to get it working!
