# Button Event Handler within a template

**URL:** <https://forum.inductiveautomation.com/t/button-event-handler-within-a-template/18700>\
**Category:** Ignition\
**Created:** [July 2, 2018, 8:33pm UTC](https://forum.inductiveautomation.com/t/button-event-handler-within-a-template/18700 "2018-07-02T20:33:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcharles](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@pcharles](https://forum.inductiveautomation.com/u/pcharles)\
**Post date:** [July 2, 2018, 8:33pm UTC](https://forum.inductiveautomation.com/t/button-event-handler-within-a-template/18700/1 "2018-07-02T20:33:51Z")

</div>

I need to make the template visibility false, when a button is clicked inside the template. I guess I am having issues with component hierarchy.  
The ‘Cancel’ button is to make the template invisiblle.  
This is what I have right now. Thanks!

```auto
event.source.parent.getComponent('abort_template.Container').visible = False 

``

<img src="//cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/inductiveautomation/original/2X/6/623c988a07640586e86968fa435dadceef5fac9a.PNG" width="501" height="500">
```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 2, 2018, 8:37pm UTC](https://forum.inductiveautomation.com/t/button-event-handler-within-a-template/18700/2 "2018-07-02T20:37:37Z")

</div>

Two things:

1. The `getComponent()` method can only access one level at a time. No dot allowed.
2. The button’s parent is already `Container`. No need to use `getComponent()` at all.

Try this:

```auto
event.source.parent.visible = False

```
