# Deleting Single Repeater Issue (wixData.remove)

**URL:** <https://forum.wixstudio.com/t/deleting-single-repeater-issue-wixdata-remove/18581>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [June 17, 2020, 10:16pm UTC](https://forum.wixstudio.com/t/deleting-single-repeater-issue-wixdata-remove/18581 "2020-06-17T22:16:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewgchoi](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/andrewgchoi/32/19676_2.png) [@andrewgchoi](https://forum.wixstudio.com/u/andrewgchoi)\
**Post date:** [June 17, 2020, 10:16pm UTC](https://forum.wixstudio.com/t/deleting-single-repeater-issue-wixdata-remove/18581/1 "2020-06-17T22:16:00Z")

</div>

Hi,

**I have done:** I created a live image update preview with the repeater and trying to delete them by clicking ‘x’ icon.  
**The issue is:** It works fine only if I exit preview mode and re-enter it. In other times, It gives error as shown below: TypeError: Cannot read property ‘\_id’ of null

Please help me!! It partially works but I get the error message If I upload the image then click X.

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

**My code is:**

```javascript
import wixData from 'wix-data';

function getData() {
 let query = wixData.query('Images');

 return query.limit(1000).find().then(results => {
        console.log('getData', results);
 return results.items;
    })
}

$w.onReady(() => {
    $w("#Imagewrite").onAfterSave(() => {
        getData().then((items) => {
            $w("#Imagelist").data = items;
        });
    });
});

export function vectorImage_click(event) {
 let item = $w("#dataset1").getCurrentItem();
    wixData.remove("Images", item._id)

        .then(() => {

 //refresh the repeater with the updated info 

            $w('#dataset1').refresh();

        }).catch((err) => {

 let errorMsg = err;

        });
}

```

---

<div class="post-metadata">

**Author:** ![tony-brunsman](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tony-brunsman](https://forum.wixstudio.com/u/tony-brunsman)\
**Post date:** [June 18, 2020, 12:10am UTC](https://forum.wixstudio.com/t/deleting-single-repeater-issue-wixdata-remove/18581/2 "2020-06-18T00:10:28Z")

</div>

Hi Andrew,

Since you are populating the repeater via query code, you are, in effect, committing yourself to that approach, and that’s fine. But then I’m seeing that you are accessing dataset functions getCurrentItem and Refresh. After assigning the results.items to the repeater, that is what it’s tied to, not a dataset. In other words, getCurrentItem is probably not returning the current record.

Have a look at the [repeater documentation introduction](https://www.wix.com/corvid/new-reference/$w/repeater/introduction) in the section called “Retrieve Repeater Item Data When Clicked”. That will give you a good idea how to proceed.

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [June 18, 2020, 12:59am UTC](https://forum.wixstudio.com/t/deleting-single-repeater-issue-wixdata-remove/18581/3 "2020-06-18T00:59:42Z")

</div>

If you are now using a repeater for this instead of a Pro Gallery as in your post from a day ago.  
[https://www.wix.com/corvid/forum/community-discussion/delete-a-image-in-temporary-gallery?origin=member\_posts\_page](https://www.wix.com/corvid/forum/community-discussion/delete-a-image-in-temporary-gallery?origin=member_posts_page)

Have you not tried the code sample in the previous post linked for deleting from a repeater, which you said was no good before as you were not using a repeater.  
[https://www.wix.com/corvid/forum/community-discussion/delete-pic-in-temporary-gallery-pre-form-submit](https://www.wix.com/corvid/forum/community-discussion/delete-pic-in-temporary-gallery-pre-form-submit)  
[https://www.wix.com/corvid/forum/feature-requests/delete-an-item-in-a-repeater](https://www.wix.com/corvid/forum/feature-requests/delete-an-item-in-a-repeater)

---

<div class="post-metadata">

**Author:** ![andrewgchoi](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/andrewgchoi/32/19676_2.png) [@andrewgchoi](https://forum.wixstudio.com/u/andrewgchoi)\
**Post date:** [June 18, 2020, 2:30am UTC](https://forum.wixstudio.com/t/deleting-single-repeater-issue-wixdata-remove/18581/4 "2020-06-18T02:30:12Z")

</div>

Thank you for the advice! I’ll try it out!

---

<div class="post-metadata">

**Author:** ![andrewgchoi](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/andrewgchoi/32/19676_2.png) [@andrewgchoi](https://forum.wixstudio.com/u/andrewgchoi)\
**Post date:** [June 18, 2020, 2:40am UTC](https://forum.wixstudio.com/t/deleting-single-repeater-issue-wixdata-remove/18581/5 "2020-06-18T02:40:50Z")

</div>

Hi! Thank you for helping me everyday! 🙂

Above code is the code sample from the link you have given to me. It currently gives me some error, which I am trying to solve here.

Pro Gallery is not working with the Remove function since It must be removed (or deleted) before insert into database.

---

<div class="post-metadata">

**Author:** ![andrewgchoi](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/andrewgchoi/32/19676_2.png) [@andrewgchoi](https://forum.wixstudio.com/u/andrewgchoi)\
**Post date:** [June 18, 2020, 9:44pm UTC](https://forum.wixstudio.com/t/deleting-single-repeater-issue-wixdata-remove/18581/6 "2020-06-18T21:44:14Z")

</div>

Thank you for the help!! It works smooth as butter!

For people, the result is shown below:

```javascript
import wixData from 'wix-data';

function getData() {
 let query = wixData.query('Images');

 return query.limit(1000).find().then(results => {
        console.log('getData', results);
 return results.items;
    })
}

$w.onReady(() => {
    $w("#Imagewrite").onAfterSave(() => {
        getData().then((items) => {
            $w("#Imagelist").data = items;
        });
    });
});

export function vectorImage_click(event) {
 let $item = $w.at(event.context);
 let clickedItemData = $item("#dataset1").getCurrentItem();
        wixData.remove("Images", clickedItemData._id)

            .then(() => {

                $w('#dataset1').refresh();

            }).catch((err) => {

 let errorMsg = err;

            });
}

```
