# \[SOLVED\] The Event Context of the repeater is not returning the correct Item Id

**URL:** <https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [August 9, 2021, 3:23pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174 "2021-08-09T15:23:35Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![developer84924](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@developer84924](https://forum.wixstudio.com/u/developer84924)\
**Post date:** [August 9, 2021, 3:23pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/1 "2021-08-09T15:23:35Z")

</div>

I have been working with repeaters for some time, and recently I have encountered an error in the event context when using OnClick functions, to avoid duplication of OnClick Funtions I’m using the following example: [https://www.wix.com/velo/reference/$w/repeater/introduction#$w\_repeater\_introduction\_repeated-item-scope.](https://www.wix.com/velo/reference/$w/repeater/introduction#$w_repeater_introduction_repeated-item-scope.)

Following the example I add this to my code:

```javascript
let clickedItemData = data.find(item => item._id === event.context.itemId);

```

event.context.itemId should return the ID of the item, in this case is the same ID as the one saved in a Collection so for example “53a57176-b52d-4b3d-b5e6-887c22822e32”.  
However recently the event.context is returning something like “item-kqkkmq3” which doesn’t make sense. The data that I’m assigning to the repeater already has the “.\_id” property and it doesn’t match the one that I’m getting.

This only happens with the live version of my website, but it doesn’t happen all the time.

---

<div class="post-metadata">

**Author:** ![developer84924](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@developer84924](https://forum.wixstudio.com/u/developer84924)\
**Post date:** [August 10, 2021, 1:55pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/2 "2021-08-10T13:55:11Z")

</div>

Update: I discovered that if the repeater is filled with items before using data to populate it, the items sort of remember the old Id, and don’t change it to the new Id, maybe is because the OnClick function is running before the repeater is populated?

Update 2: When a repeater is filled a second time, the ID of the item changes and the repeater automatically ads something like “\_p2\_p3” at the end of the ID of the item, in the context

---

<div class="post-metadata">

**Author:** ![siliconvalleywoodtur](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@siliconvalleywoodtur](https://forum.wixstudio.com/u/siliconvalleywoodtur)\
**Post date:** [August 12, 2021, 5:45pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/3 "2021-08-12T17:45:54Z")

</div>

I have the same problem. My code used to work correctly until a week or so ago. But now I have the same problem. I have put a work around as follows. But this bug is a serious bug and hard for most people to trace. It does not happen on the first try. But from the second time onwards.

You can try out my sample site isolating this bug. Click on one of the items in the repeater. It should show only the matching lines. Then do a ‘Show All’ and do another one. If you click on the same item as before it does not add the '_p__’ to the id. But if you click on any of the other items, then those itemIds have the p_ at the end.

[https://svwoodturners.wixsite.com/repeaterbug](https://svwoodturners.wixsite.com/repeaterbug)

import wixData from ‘wix-data’ ;

$w . onReady ( function () {  
$w ( “#foo” ). onClick (( event ) =\> {  
let itemId = event . context . itemId ;  
itemId = bugfix ( itemId );  
let data = $w ( “#fooRepeater” ). data ;  
let itemData = data . find (( item ) =\> item . \_id === itemId );  
if ( itemData !== **undefined** ) {  
$w ( ‘#barDS’ ). setFilter ( wixData . filter (). eq ( ‘title’ , itemData . title ));  
}  
})  
});

export function showAllBtn\_click ( event ) {  
$w ( ‘#barDS’ ). setFilter ( wixData . filter ())  
. then (() =\> $w ( ‘#barDS’ ). refresh ())  
}

function bugfix ( itemId ) {  
console . log ( 'itemId before fix = ’ , itemId );  
let i = itemId . indexOf ( ‘_p_’ );  
if ( i !== - 1 ) {  
console . log ( ‘\*\*\*\*\* BUG \*\*\*\*\* the itemId should not end in _p_\* . This is a bug in repeater code.’ )  
itemId = itemId . substr ( 0 , i );  
}  
console . log ( 'itemId after fix = ’ , itemId );  
console . log ( ‘-------------------------’ );  
**return** itemId ;  
}

---

<div class="post-metadata">

**Author:** ![pptgames](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/pptgames/32/1306_2.png) [@pptgames](https://forum.wixstudio.com/u/pptgames)\
**Post date:** [August 12, 2021, 10:52pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/4 "2021-08-12T22:52:49Z")

</div>

I have reported this problem [here](https://www.wix.com/velo/forum/coding-with-velo/bug-repeater-element-context-itemid) and provided a simple temporary fix/wordaround.

---

<div class="post-metadata">

**Author:** ![marlowe-shaeffer](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/marlowe-shaeffer/32/669_2.png) [@marlowe-shaeffer](https://forum.wixstudio.com/u/marlowe-shaeffer)\
**Post date:** [August 12, 2021, 11:26pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/5 "2021-08-12T23:26:00Z")

</div>

Thanks for reporting. We’ll let you know when the issue is resolved.

---

<div class="post-metadata">

**Author:** ![developer84924](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@developer84924](https://forum.wixstudio.com/u/developer84924)\
**Post date:** [August 13, 2021, 1:25pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/6 "2021-08-13T13:25:13Z")

</div>

Yeah, I also have a workaround, Since Wix uses 36 characters as an Id for the collection items I just slice the id like this:

```javascript
let clickedItemData = $w("#repeater").data.find(item = item._id === e.context.itemId.slice(0,36);

```

However this only works with this bug specifically, I’m also getting a completely different Id when clicking the first item in the repeater, something like “item\_kkqkkq” which is the ID that Wix gives to the items you added manually to the repeater and not the one you assign with code.

---

<div class="post-metadata">

**Author:** ![marlowe-shaeffer](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/marlowe-shaeffer/32/669_2.png) [@marlowe-shaeffer](https://forum.wixstudio.com/u/marlowe-shaeffer)\
**Post date:** [August 13, 2021, 7:18pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/7 "2021-08-13T19:18:11Z")

</div>

Hi everyone,

Thanks for sharing your workarounds. Our dev team is working on a solution, and we will provide an update as soon as more information is available. Thanks for your patience!

---

<div class="post-metadata">

**Author:** ![liandrodourado](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/liandrodourado/32/29683_2.png) [@liandrodourado](https://forum.wixstudio.com/u/liandrodourado)\
**Post date:** [August 14, 2021, 5:25pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/8 "2021-08-14T17:25:50Z")

</div>

```javascript
I have this same problem, when I perform one or two searches in the database it happens with the repeater that mixes the Ids

```

---

<div class="post-metadata">

**Author:** ![marlowe-shaeffer](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/marlowe-shaeffer/32/669_2.png) [@marlowe-shaeffer](https://forum.wixstudio.com/u/marlowe-shaeffer)\
**Post date:** [August 16, 2021, 2:25pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/9 "2021-08-16T14:25:30Z")

</div>

This issue is now resolved. Please let us know if you continue to experience any problems. Thanks!

---

<div class="post-metadata">

**Author:** ![developer84924](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@developer84924](https://forum.wixstudio.com/u/developer84924)\
**Post date:** [August 17, 2021, 1:12pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/10 "2021-08-17T13:12:15Z")

</div>

@marlowe-shaeffer I continue to experience the problem of mixed IDs, The context is still returning the incorrect ID “item-kqmqnq3q” instead of the correct one “53a57176-b52d-4b3d-b5e6-887c22822e32”  
Edit: and still the ID has the “\_p\_2” at the end when the repeater is refilled with new data.

---

<div class="post-metadata">

**Author:** ![marlowe-shaeffer](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/marlowe-shaeffer/32/669_2.png) [@marlowe-shaeffer](https://forum.wixstudio.com/u/marlowe-shaeffer)\
**Post date:** [August 17, 2021, 4:54pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/11 "2021-08-17T16:54:50Z")

</div>

@developer84924 Have you republished your site since we deployed the fix? You might be seeing an old, cached version.

Can you please share the URL for your site so we can investigate? Thanks.

---

<div class="post-metadata">

**Author:** ![developer84924](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@developer84924](https://forum.wixstudio.com/u/developer84924)\
**Post date:** [August 18, 2021, 1:00pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/12 "2021-08-18T13:00:47Z")

</div>

@marlowe-shaeffer Yeah I already published the site and tried clearing my cache.

[https://pablo55557.wixsite.com/balmtattoo/aftercare-new](https://pablo55557.wixsite.com/balmtattoo/aftercare-new)

To replicate the bug click on the image of the first item while the developer console is open and you should be able to see the incorrect id.

---

<div class="post-metadata">

**Author:** ![marlowe-shaeffer](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/marlowe-shaeffer/32/669_2.png) [@marlowe-shaeffer](https://forum.wixstudio.com/u/marlowe-shaeffer)\
**Post date:** [August 18, 2021, 3:16pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/13 "2021-08-18T15:16:11Z")

</div>

@developer84924 Update: We had to revert the fix because it caused new regressions. I’ll let you know once it’s resolved. Sorry for the inconvenience!

---

<div class="post-metadata">

**Author:** ![marlowe-shaeffer](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/marlowe-shaeffer/32/669_2.png) [@marlowe-shaeffer](https://forum.wixstudio.com/u/marlowe-shaeffer)\
**Post date:** [August 18, 2021, 9:31pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/14 "2021-08-18T21:31:27Z")

</div>

We investigated your site, and you’re experiencing a different bug. We have a ticket open on this issue and I’ll let you know when it’s resolved.

---

<div class="post-metadata">

**Author:** ![prashanthbhaskaran](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/prashanthbhaskaran/32/10176_2.png) [@prashanthbhaskaran](https://forum.wixstudio.com/u/prashanthbhaskaran)\
**Post date:** [August 19, 2021, 3:07am UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/15 "2021-08-19T03:07:25Z")

</div>

Hi @marlowe-shaeffer has this issue been resolved yet please? A bit confused with your response above regarding a different bug.

---

<div class="post-metadata">

**Author:** ![developer84924](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@developer84924](https://forum.wixstudio.com/u/developer84924)\
**Post date:** [August 19, 2021, 1:36pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/16 "2021-08-19T13:36:17Z")

</div>

@marlowe-shaeffer Hello!, could you please explain what bug are you trying to solve and what bugs are currently resolved?, The original post has information on 2 bugs, one when the context returns a completely different id than the one you assign, and the other when the context returns the correct id but also adds “_p_” at the end. Thank you

---

<div class="post-metadata">

**Author:** ![marlowe-shaeffer](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/marlowe-shaeffer/32/669_2.png) [@marlowe-shaeffer](https://forum.wixstudio.com/u/marlowe-shaeffer)\
**Post date:** [August 19, 2021, 2:58pm UTC](https://forum.wixstudio.com/t/solved-the-event-context-of-the-repeater-is-not-returning-the-correct-item-id/35174/17 "2021-08-19T14:58:57Z")

</div>

@developer84924 Both bugs should now be resolved; we just rolled out fixes a few minutes ago. If a new issue arises, or an old one presents itself, please create a new post for each issue (to avoid confusion) and tag me. Thanks.
