# Conditionally Hide/Show Button on Repeater

**URL:** <https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [April 6, 2020, 10:36pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343 "2020-04-06T22:36:18Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan38194](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dan38194](https://forum.wixstudio.com/u/dan38194)\
**Post date:** [April 6, 2020, 10:36pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/1 "2020-04-06T22:36:18Z")

</div>

I know there have been a million posts on this, and I’ve tried them all. I’ve got a button in a repeater that I need to hide if there’s no value to it. The field is called “series”

```javascript
export function repeater1_itemReady($item, itemData, index) {
if(itemData.series === "") {
$w("#button5").hide();
}
else {     
$w("#button5").show();
}
}

```

That doesn’t work at all. I’m a novice here. If someone could lend some advice I’d be very grateful!

---

<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:** [April 7, 2020, 12:47am UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/2 "2020-04-07T00:47:53Z")

</div>

Hi Dan,

There have been quite a few posts on this, but to reiterate, to work with an element in an individual row of a repeater, you need to refer to the element with the selector function $item instead of the typical $w.

```javascript
export function repeater1_itemReady($item, itemData, index) {
    if(itemData.series === "") {
        $item("#button5").hide();
    } else {     
        $item("#button5").show();
    }
}

```

---

<div class="post-metadata">

**Author:** ![dan38194](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dan38194](https://forum.wixstudio.com/u/dan38194)\
**Post date:** [April 7, 2020, 6:42pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/3 "2020-04-07T18:42:40Z")

</div>

Hi @tony-brunsman - I appreciate your reply! So I had tried the above, and it just creates a blank button if I use that code.

![](https://us1.discourse-cdn.com/wix/original/3X/6/8/68fe5acbd64c77ddee4db23db06f55d5ae204122.png)

---

<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:** [April 7, 2020, 7:43pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/4 "2020-04-07T19:43:11Z")

</div>

@dan38194 Could you upload an image of what it looks like when the button is visible?

---

<div class="post-metadata">

**Author:** ![dan38194](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dan38194](https://forum.wixstudio.com/u/dan38194)\
**Post date:** [April 7, 2020, 7:56pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/5 "2020-04-07T19:56:42Z")

</div>

Sure! @tony-brunsman - see below.

Also, here is the only code I’ve got on the page right now. Thanks again!

```javascript
export function repeater1_itemReady($item, itemData, index) {
if(itemData.series === "") {
$item("#button5").hide();
} else {
$item("#button5").show();
}
}
import wixWindow from 'wix-window'; //import Wix libary wixWindow
$w.onReady(function () {
let isMobile = wixWindow.formFactor.match('Mobile') //use libary to check is user using mobile
if(isMobile){
$w('#table1').show() // if user using mobile, the element show
}
})

```

 ![](https://us1.discourse-cdn.com/wix/original/3X/4/0/40febd6ab4bee0c70d1db46a410f6b6516e7c3a0.jpeg)

---

<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:** [April 7, 2020, 8:30pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/6 "2020-04-07T20:30:20Z")

</div>

Dan, the import statements and onReady should be at the top of the page and not inside any particular function. After making that change, let’s see if you continue to have the “blank button” behavior.

```javascript
import wixWindow from 'wix-window'; 
$w.onReady(function () {
    let isMobile = wixWindow.formFactor.match('Mobile')
    if(isMobile){
        $w('#table1').show()  
    }
})
export function repeater1_itemReady($item, itemData, index) {
    if(itemData.series === "") {
        $item("#button5").hide();
    } else {
        $item("#button5").show();
    }
}

```

---

<div class="post-metadata">

**Author:** ![dan38194](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dan38194](https://forum.wixstudio.com/u/dan38194)\
**Post date:** [April 7, 2020, 10:01pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/7 "2020-04-07T22:01:52Z")

</div>

Hi @tony-brunsman - thanks again for your time. Unfortunately it’s the same result. It’s almost like the code isn’t doing anything.

Question - the field “series” is a reference field, referencing a different content collection.

Thanks again.

 ![](https://us1.discourse-cdn.com/wix/original/3X/6/4/64843b7e57de4ce3d805c76d460f2a58863a70db.jpeg)

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

---

<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:** [April 7, 2020, 10:31pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/8 "2020-04-07T22:31:11Z")

</div>

Since it is a reference field, you need to specify which field in the referenced collection that you are checking the “emptyness” of. An object that contains all of the field values is what itemData.series returns. So, if the field in the referenced table is named “series”, you would refer to it as itemData.series.series.

```javascript
export function repeater1_itemReady($item, itemData, index) {
    if(itemData.series.series === "") {
        $item("#button5").hide();
    } else {
        $item("#button5").show();
    }
}

```

---

<div class="post-metadata">

**Author:** ![dan38194](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dan38194](https://forum.wixstudio.com/u/dan38194)\
**Post date:** [April 7, 2020, 10:45pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/9 "2020-04-07T22:45:25Z")

</div>

Hi @tony-brunsman - thanks for this. I tried the above and still, same issue. I also tried events.series and series.events (name of referenced collection) and same issue…kind of lost here. 😕

---

<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:** [April 8, 2020, 12:49am UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/10 "2020-04-08T00:49:06Z")

</div>

It might help to put a console.log statement in there so you can really see what you’re dealing with.

```javascript
export function repeater1_itemReady($item, itemData, index) {
  console.log(itemData.series);
    if(itemData.series.series === "") {
        $item("#button5").hide();
    } else {
        $item("#button5").show();
    }
}

```

---

<div class="post-metadata">

**Author:** ![deecinq](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@deecinq](https://forum.wixstudio.com/u/deecinq)\
**Post date:** [April 6, 2023, 6:48pm UTC](https://forum.wixstudio.com/t/conditionally-hide-show-button-on-repeater/28343/11 "2023-04-06T18:48:20Z")

</div>

I’m trying the same thing. I have buttons/icons for in a repeater: Website, Facebook, Insta, LinkedIn. All connected to data. Not all people will have all of these elements, so I want to hide if no value in data. I am reading through this an not sure if any of the above worked, or will work for my repeater. I’ve tried the first two.
