# .getCurrentItem always gets the item from the first repeater

**URL:** <https://forum.wixstudio.com/t/getcurrentitem-always-gets-the-item-from-the-first-repeater/51751>\
**Category:** Ask the community\
**Tags:** code, cms\
**Created:** [August 22, 2023, 10:39am UTC](https://forum.wixstudio.com/t/getcurrentitem-always-gets-the-item-from-the-first-repeater/51751 "2023-08-22T10:39:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user199](https://avatars.discourse-cdn.com/v4/letter/u/c89c15/32.png) [@user199](https://forum.wixstudio.com/u/user199)\
**Post date:** [August 22, 2023, 10:39am UTC](https://forum.wixstudio.com/t/getcurrentitem-always-gets-the-item-from-the-first-repeater/51751/1 "2023-08-22T10:39:32Z")

</div>

I am new to wix and have been following some tutorials. I have run into an issue where .getCurrentItem gets the first item instead of the item from the repeater that I click. I am trying to have a button that downloads the associated image, but it always downloads the first one. Any help is appreciated.  
Here is the code:

```javascript
$w.onReady(function () {
$w('#button19').target = "_blank";
$w('#button19').onMouseIn( (event) => {
    let item = $w('#dataset1').getCurrentItem();

    let picture = item.image;

    let url = picture.split("/")[3];

    let filename = item.fileName;
   
    $w('#button19').link = `https://static.wixstatic.com/media/${url}?dn=${filename}`;
	    
} );

```

---

<div class="post-metadata">

**Author:** ![thomasj](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thomasj/32/30791_2.png) [@thomasj](https://forum.wixstudio.com/u/thomasj)\
**Post date:** [August 22, 2023, 7:38pm UTC](https://forum.wixstudio.com/t/getcurrentitem-always-gets-the-item-from-the-first-repeater/51751/2 "2023-08-22T19:38:59Z")

</div>

While datasets have a current item index, they do not automatically match the item you click on within a repeater unless you change the index using [setCurrentItemIndex( )](https://www.wix.com/velo/reference/wix-dataset/dataset/setcurrentitemindex)

Instead of changing the dataset index, you can add a event handler for the repeated button in order to get the data necessary to generate a download link.

You can accomplish this using the repeater element’s [onItemReady()](https://www.wix.com/velo/reference/$w/repeater/onitemready) function

**Example**

```javascript
$w.onReady(function () {

    $w('#repeater').onItemReady(($item, itemData, index) => {
		$item('#repeatedButton').onClick(() => {
			//Handle Image Download
			console.log(itemData); //This is the item data object associated to the button that the user clicks
		})
    });

});

```
