# Hiding An Element from Dataset in a repeater when field is empty

**URL:** <https://forum.wixstudio.com/t/hiding-an-element-from-dataset-in-a-repeater-when-field-is-empty/63116>\
**Category:** Ask the community\
**Tags:** wix-forum, question, code, cms, wix\
**Created:** [September 27, 2024, 9:52am UTC](https://forum.wixstudio.com/t/hiding-an-element-from-dataset-in-a-repeater-when-field-is-empty/63116 "2024-09-27T09:52:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loeka\_Baeyens](https://avatars.discourse-cdn.com/v4/letter/l/e99b99/32.png) [@Loeka\_Baeyens](https://forum.wixstudio.com/u/Loeka_Baeyens)\
**Post date:** [September 27, 2024, 9:52am UTC](https://forum.wixstudio.com/t/hiding-an-element-from-dataset-in-a-repeater-when-field-is-empty/63116/1 "2024-09-27T09:52:40Z")

</div>

**Question:**  
How can I hide the image in a repeater when the dataset field is empty? Currently, when the “Samenwerking Logo” field in my dataset is empty, a white placeholder or blank image is still displayed. I want the image to be completely hidden if no logo is available for that item.

**Product:**  
Wix Editor (Velo Code)

**What are you trying to achieve:**  
I’m trying to display an image in a repeater only if the dataset field (for a logo) contains a valid image URL. If the dataset field is empty or doesn’t have a logo, the image should be hidden entirely, without showing any placeholders or white space.

**What have you already tried:**

- I’ve set up the repeater and connected the image field to the dataset (“Samenwerking Logo”).
- I’ve used Velo code to attempt to show/hide the image based on the field’s data.
- I tried resetting the image `src` to `null` and using `.hide()` to remove the image, but I still get white placeholders or an empty image appearing.
- I’ve reviewed Wix forums and articles related to repeaters and dynamic images, but haven’t found a solution that works.

**Additional information:**

- My repeater ID is `#repeater1`, the dataset ID is `#dataset1`, and the image ID is `#image164`.
- I am using the following code to hide the image, but it still shows a white placeholder when the logo is missing:

```javascript
$w.onReady(function () {
    $w("#dataset1").onReady(function () {
        $w("#repeater1").onItemReady(($item, itemData) => {
            if (itemData.samenwerkingLogo) {
                $item("#image164").src = itemData.samenwerkingLogo;
                $item("#image164").show();
            } else {
                $item("#image164").src = null;
                $item("#image164").hide();
            }
        });
    });
});

```

I’ve also checked that no default placeholder images are set for the image element. What should I adjust to ensure no white placeholder appears when the field is empty?

---

<div class="post-metadata">

**Author:** ![DeanAyalon](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/deanayalon/32/94633_2.png) [@DeanAyalon](https://forum.wixstudio.com/u/DeanAyalon)\
**Post date:** [September 27, 2024, 10:32am UTC](https://forum.wixstudio.com/t/hiding-an-element-from-dataset-in-a-repeater-when-field-is-empty/63116/3 "2024-09-27T10:32:19Z")

</div>

The white space you’re experiencing is because you’re using the `show/hide` functions, rather than `expand/collapse`

Try doing

```js
$item('#image164').collapse()

```

Also, I wouldn’t wait for dataset.onReady to set the repeater.onItemReady.  
And you should probably assign better tags than `#image164`

---

<div class="post-metadata">

**Author:** ![Loeka\_Baeyens](https://avatars.discourse-cdn.com/v4/letter/l/e99b99/32.png) [@Loeka\_Baeyens](https://forum.wixstudio.com/u/Loeka_Baeyens)\
**Post date:** [September 30, 2024, 9:00am UTC](https://forum.wixstudio.com/t/hiding-an-element-from-dataset-in-a-repeater-when-field-is-empty/63116/4 "2024-09-30T09:00:46Z")

</div>

Thank you for your help!  
Unfortunately this didn’t work and I still get a white placeholder ☹
