# Calling Javascript function on Click

**URL:** <https://forums.fusetools.com/t/calling-javascript-function-on-click/5618>\
**Category:** How-to Discussions\
**Created:** [February 19, 2017, 9:18am UTC](https://forums.fusetools.com/t/calling-javascript-function-on-click/5618 "2017-02-19T09:18:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![whalanz](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@whalanz](https://forums.fusetools.com/u/whalanz)\
**Post date:** [February 19, 2017, 9:18am UTC](https://forums.fusetools.com/t/calling-javascript-function-on-click/5618/1 "2017-02-19T09:18:37Z")

</div>

Hi, I am trying to use javascript to log a click event but I can’t seem to make it happen no matter what I try. I am an absolute beginner and I’m sure I am (obviously) doing something wrong here. Can anybody lead me in the right direction? Thanks in advance.

Here is what I have  
It results in the initial ‘handled1’ being logged but not the function with ‘handled2’.

Though the button does respond visually to a click, the function isn’t executed.

```
<App>
<JavaScript>
    console.log("Handled1");
	
	function f1(){
        console.log("Handled2");
	}
</JavaScript>

<StackPanel>
	<Button Text="Click Me" Clicked="{f1}" />
</StackPanel>
</App>
```

---

<div class="post-metadata">

**Author:** ![Jack\_the\_Bear](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@Jack\_the\_Bear](https://forums.fusetools.com/u/Jack_the_Bear)\
**Post date:** [February 19, 2017, 3:48pm UTC](https://forums.fusetools.com/t/calling-javascript-function-on-click/5618/2 "2017-02-19T15:48:41Z")

</div>

```auto
module.exports = {
	f1: f1
}

```

---

<div class="post-metadata">

**Author:** ![whalanz](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@whalanz](https://forums.fusetools.com/u/whalanz)\
**Post date:** [February 19, 2017, 9:23pm UTC](https://forums.fusetools.com/t/calling-javascript-function-on-click/5618/3 "2017-02-19T21:23:51Z")

</div>

That done the trick thank you! I should have known as {f1} is in the same shortcode format which I had noticed but this solution never came to mind. Thanks again.

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [September 27, 2017, 3:58pm UTC](https://forums.fusetools.com/t/calling-javascript-function-on-click/5618/5 "2017-09-27T15:58:02Z")

</div>

@Horchata: yes and no. The arguments are implicitly the data context you are clicking on, so the answer depends on your particular use case.

Please explain what you are trying to do in a new forum thread, share some code to show what you have tried so far and we’ll take it from there.
