# Check if bound callback method is undefined

**URL:** <https://discourse.aurelia.io/t/check-if-bound-callback-method-is-undefined/1265>\
**Category:** Help Requests\
**Created:** [May 31, 2018, 7:52am UTC](https://discourse.aurelia.io/t/check-if-bound-callback-method-is-undefined/1265 "2018-05-31T07:52:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nautilus](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/nautilus/32/715_2.png) [@nautilus](https://discourse.aurelia.io/u/nautilus)\
**Post date:** [May 31, 2018, 7:52am UTC](https://discourse.aurelia.io/t/check-if-bound-callback-method-is-undefined/1265/1 "2018-05-31T07:52:30Z")

</div>

Hey folks

Short question. We have a custom element with a callback attribute. This callback attribute might be undefined (generic stuff). Since Aurelia wraps a function around passed value, even if value is undefined, we have no idea how to check it.

```auto
// fancy custom element 

export class FancyCustomElement {
  //this guy might be undefined but Aurelia wraps a function which makes it impossible to check if it's undefined.
  @bindable public onChange?: () => void;
}

```

```auto
<!-- model view -->
<template>
  <fancy on-change.call="onChange()"></fancy>
</template>

```

```auto
// view model
export class ViewModel {
  public onChange = undefined;
}

```

Thanks for your help

---

<div class="post-metadata">

**Author:** ![MaximBalaganskiy](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/maximbalaganskiy/32/831_2.png) [@MaximBalaganskiy](https://discourse.aurelia.io/u/MaximBalaganskiy)\
**Post date:** [May 31, 2018, 11:10am UTC](https://discourse.aurelia.io/t/check-if-bound-callback-method-is-undefined/1265/2 "2018-05-31T11:10:07Z")

</div>

Instead of that raise an event on an element and bind a delegate/trigger to it

---

<div class="post-metadata">

**Author:** ![dweber019](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/dweber019/32/628_2.png) [@dweber019](https://discourse.aurelia.io/u/dweber019)\
**Post date:** [June 3, 2018, 7:55pm UTC](https://discourse.aurelia.io/t/check-if-bound-callback-method-is-undefined/1265/3 "2018-06-03T19:55:41Z")

</div>

Or do it with a normal binding (not call).

.bind instead of .call

> **[Aurelia bind instead call - CodeSandbox](https://codesandbox.io/s/n0272xnkwp)**
>
> The online code editor tailored for web applications

---

<div class="post-metadata">

**Author:** ![nautilus](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/nautilus/32/715_2.png) [@nautilus](https://discourse.aurelia.io/u/nautilus)\
**Post date:** [June 3, 2018, 8:48pm UTC](https://discourse.aurelia.io/t/check-if-bound-callback-method-is-undefined/1265/4 "2018-06-03T20:48:21Z")

</div>

@dweber019 Thanks, seems to work 👍
