# Delete Pic in Temporary Gallery (pre-form submit)

**URL:** <https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [May 12, 2018, 3:03pm UTC](https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523 "2018-05-12T15:03:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [May 12, 2018, 3:03pm UTC](https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523/1 "2018-05-12T15:03:03Z")

</div>

Hi guys

**Have already:**  
I have my code to upload multiple images to a temporary gallery (from a single upload button) for people to preview before they submit the images to a gallery.

**Need:**  
I’m trying to add an “image delete button” to remove the current image being viewed in the Temporary Gallery.

Something like:

```javascript
export function imagedeletebutton_click(event, $w) {
let currentIndex = $w("#gallery1").currentIndex;
let item = $w("#gallery1").items[currentIndex].src;
item.remove();
} 

```

Does anyone have any ideas?

Many thanks!

Thomas

---

<div class="post-metadata">

**Author:** ![dalia-simons](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dalia-simons/32/1199_2.png) [@dalia-simons](https://forum.wixstudio.com/u/dalia-simons)\
**Post date:** [May 15, 2018, 6:38am UTC](https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523/2 "2018-05-15T06:38:31Z")

</div>

Did you try getting the items , removing one from the array and then setting the items back on the gallery?

> **[Gallery - Velo API Reference - Wix.com](https://www.wix.com/velo/reference/$w/gallery)**
>
> A Gallery displays multiple items.

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [May 31, 2018, 8:10am UTC](https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523/3 "2018-05-31T08:10:02Z")

</div>

Hi Dalia

Many thanks for the response. Sorry, I’ve been away this month so I haven’t been very active with the forum.

I decided a different approach would be easier. I’ve changed it to a repeater, put the image as the whole repeater and am filtering results from a dataset on the page instead. (it’s filtered via a g.u.i.d code generated on the page).

This is what it looks like:

![](https://us1.discourse-cdn.com/wix/original/3X/8/7/871aa27a54ba2010ed2bd66a59caf41c8d058ec4.jpeg)

However, I’m trying to make the little “X” button on the repeater delete the item in the dataset, but i’m struggling.

This is my code to date, but it’s not responding:

```javascript
export function iconButton1_click(event, $w) {
	
		let item = $w("#dataset1").getCurrentItem();
		let title = $w("#text153").text; // key generated as page loads
		wixData.remove("images", item)
	
		$w("#dataset1").onReady( () => {

			$w("#dataset1").setFilter(wixData.filter().eq("title", title)); // should filter dataset to match text153
						
		})
}

```

Any idea on how to action this to delete the current item on the dataset?

Many thanks for the help to date!

Thomas

---

<div class="post-metadata">

**Author:** ![dalia-simons](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dalia-simons/32/1199_2.png) [@dalia-simons](https://forum.wixstudio.com/u/dalia-simons)\
**Post date:** [May 31, 2018, 8:21am UTC](https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523/4 "2018-05-31T08:21:03Z")

</div>

Hi Thomas  
The remove functions needs the id as parameter : [wix-data - Velo API Reference - Wix.com](https://www.wix.com/code/reference/wix-data.html#remove)

I suggest writing something like this :  
wixData.remove(“images”, item.\_id)  
.then(() =\> {  
//refresh the repeater with the updated info  
$w(’ [#r](https://www.wix.com/code/home/forum/search/posts%3Fquery=%23table1) epeater1’).refresh();  
}) .catch((err) =\> {  
let errorMsg = err;  
});

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [May 31, 2018, 11:57am UTC](https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523/5 "2018-05-31T11:57:58Z")

</div>

Hi Dalia

Thanks! It worked perfectly 🙂

However, the repeater isn’t refreshing as expected. It says _“it does not exist on the repeater”_

Many thanks

Thomas

---

<div class="post-metadata">

**Author:** ![dalia-simons](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dalia-simons/32/1199_2.png) [@dalia-simons](https://forum.wixstudio.com/u/dalia-simons)\
**Post date:** [June 3, 2018, 6:38am UTC](https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523/6 "2018-06-03T06:38:07Z")

</div>

Hi Thomas  
It turns out there is a much easier way that will also refresh your repeater:  
export function iconButton1\_click(event, $w) {  
$w(“#dataset1”).remove()  
.then( () =\> {  
console.log(“Done removing current item”);  
} );  
}  
I hope that works better 🙂

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [June 4, 2018, 1:23am UTC](https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523/7 "2018-06-04T01:23:49Z")

</div>

Works perfectly!

Many thanks for your help, Dalia 🙂

---

<div class="post-metadata">

**Author:** ![gideon](https://avatars.discourse-cdn.com/v4/letter/g/7ba0ec/32.png) [@gideon](https://forum.wixstudio.com/u/gideon)\
**Post date:** [June 18, 2019, 3:50pm UTC](https://forum.wixstudio.com/t/delete-pic-in-temporary-gallery-pre-form-submit/33523/8 "2019-06-18T15:50:40Z")

</div>

Hi Thomas,

You said in your OP that you have code already to push images to a temporary gallery. Would you be able to share that? That is exactly what I am trying to do, and I’ve been running into issues.
