Confusion relating to calling a function from a button

Hi there,

The literature on this is not that clear. I have a button that, when clicked should call a function. The way I interpreted the structure is like so:

    <div class="cal-header1-left">
        <span><button class="cal-button-arrow" type="button" click.delegate="MoveCalendarBack()">Left</button></span>

I placed the simple function in the associated custom elements’s view model:

     public MoveCalendarBack() {
              this.schedulerResources.firstDayOfWeek.add(-5, 'days');

I get this error:

Uncaught Error: moveCalendarBack is not a function
at getFunction (aurelia-binding.js?5f98:1998)
at CallScope.evaluate (aurelia-binding.js?5f98:1515)
at Listener.callSource (aurelia-binding.js?5f98:5232)
at Listener.handleEvent (aurelia-binding.js?5f98:5241)
at HTMLDocument.handleDelegatedEvent (aurelia-binding.js?5f98:3306)

Two questions… am I doing this correctly?
and… if not what I am missing or how is it supposed be done - calling a function when a button is clicked.


1 Like

Looks like a casing issue from the error message.
I just checked how I use it, and all the functions are camel case so myFunction() not MyFunction().

Using TS btw.

1 Like