# Delete record at index not working as expected

**URL:** <https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657>\
**Category:** Ask us anything\
**Created:** [November 30, 2023, 7:24pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657 "2023-11-30T19:24:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikm3103](https://avatars.discourse-cdn.com/v4/letter/e/c37758/32.png) [@erikm3103](https://community.weweb.io/u/erikm3103)\
**Post date:** [November 30, 2023, 7:24pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/1 "2023-11-30T19:24:38Z")

</div>

![Screenshot 2023-11-30 at 20.20.10](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/c/cccc075e701bdab03531c91759219bd8b41ae5ea.png)  
I’m having some issues with deleting a record at index.

From the picture above I have 2 records. In the next step I proceed with deleting **record with the amount = 1**.

 ![Screenshot 2023-11-30 at 20.21.42](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/c/c63ec55d08816db65f33333a7ca6212b73b10d62.png)  
Now that is is deleted, in the actual array, it works correctly as it removes the record at index 1, but for some reason, in the UI it always just deletes the last record.

 ![Screenshot 2023-11-30 at 20.21.48](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/8/849d23571d6487c3502efe803df339ad8079d47c.png)  
 ![Screenshot 2023-11-30 at 20.24.16](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/1/1788980a1757b13545c3795832d1246f1c15521c.png)

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 30, 2023, 7:41pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/2 "2023-11-30T19:41:43Z")

</div>

Might it be that instead of item.index, you’re passing the whole object? Also, in WeWeb (as in JavaScript) the item number one (the first one in an array) actually has the index of 0 (not 1 - that’s the second item in an array).

If the Action you’re using, is bound to the trashcan icon, and that triggers the delete (remove at index), then you need to pass only the item.index (instead of item.data).

---

<div class="post-metadata">

**Author:** ![erikm3103](https://avatars.discourse-cdn.com/v4/letter/e/c37758/32.png) [@erikm3103](https://community.weweb.io/u/erikm3103)\
**Post date:** [November 30, 2023, 7:54pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/3 "2023-11-30T19:54:18Z")

</div>

![Screenshot 2023-11-30 at 20.53.23](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/dd82de9d4ab1d275d814218b291db9b754cc21e9.png)

Ah yes, sorry it was originally on index, but was testing with item.data to see if it helped. Anyways, the issue is when the same when set to item.index.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 30, 2023, 8:01pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/4 "2023-11-30T20:01:04Z")

</div>

That is weird indeed. Seems like the amount is actually null? Not even the amount:2 that you show in the previous screenshot? Or?

---

<div class="post-metadata">

**Author:** ![erikm3103](https://avatars.discourse-cdn.com/v4/letter/e/c37758/32.png) [@erikm3103](https://community.weweb.io/u/erikm3103)\
**Post date:** [November 30, 2023, 8:09pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/5 "2023-11-30T20:09:47Z")

</div>

No, I just logged in and out again, thats why. It’s only the UI part thats off.

Would it help with a loom?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 30, 2023, 8:13pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/6 "2023-11-30T20:13:59Z")

</div>

It would definitely be clearer)

---

<div class="post-metadata">

**Author:** ![erikm3103](https://avatars.discourse-cdn.com/v4/letter/e/c37758/32.png) [@erikm3103](https://community.weweb.io/u/erikm3103)\
**Post date:** [November 30, 2023, 8:19pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/7 "2023-11-30T20:19:01Z")

</div>

> **[Understanding Item Deletion in the UI](https://www.loom.com/share/086144aa54b142e08b9b438bc042dd45)**
>
> In this video, I demonstrate how to delete items in the UI and explain the workflow. I show you how to add items and delete them using the delete button. However, I also highlight a bug where the UI displays the wrong item after deletion. I request...

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 30, 2023, 8:28pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/8 "2023-11-30T20:28:09Z")

</div>

Might the binding be the issue? Are you binding the context.item.data.amount to the init value of your input?

---

<div class="post-metadata">

**Author:** ![erikm3103](https://avatars.discourse-cdn.com/v4/letter/e/c37758/32.png) [@erikm3103](https://community.weweb.io/u/erikm3103)\
**Post date:** [November 30, 2023, 8:30pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/9 "2023-11-30T20:30:59Z")

</div>

No I’m not as you can see here:

 ![Screenshot 2023-11-30 at 21.29.51](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/9/96321b3c0d03c1cf1740476b4d5d6ce4124b300e.png)

Here is the workflow to create the new object:

 ![Screenshot 2023-11-30 at 21.29.37](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/c/cff396bf5b5dd53e44305ece6103a35a50081fb9.png)

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 30, 2023, 8:32pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/10 "2023-11-30T20:32:06Z")

</div>

Yup, you need to actually bind the init value to the value of your data. Now WeWeb doesn’t know what to put in there, as you’ve not specifically told it, so it just takes whatever was there.

---

<div class="post-metadata">

**Author:** ![erikm3103](https://avatars.discourse-cdn.com/v4/letter/e/c37758/32.png) [@erikm3103](https://community.weweb.io/u/erikm3103)\
**Post date:** [November 30, 2023, 8:32pm UTC](https://community.weweb.io/t/delete-record-at-index-not-working-as-expected/5657/11 "2023-11-30T20:32:45Z")

</div>

Worked! Thanks Broberto:))
