Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple triggers in Aurelia

Tags:

aurelia

I want to trigger two different methods in aurelia, what's the best way to achieve this?

<a click.trigger="toggleSize(size.parts)" click.delegate="refreshPanel()" click.trigger="viewUtility.closeStickyDropdown($event)">
like image 331
Akshay Khot Avatar asked Dec 04 '22 00:12

Akshay Khot


2 Answers

What I would probably do is the following

HTML

<a click.delegate="yourFunction($event, size.parts)">

Javascript

yourFunction(event, parts) {
    this.toggleSize(size.parts);
    this.refreshPanel();
    this.viewUtility.closeStickyDropdown(event); //Depends on what viewUtility is.
}
like image 57
DevNebulae Avatar answered Feb 26 '23 22:02

DevNebulae


If you do want to have multiple triggers, in declarative form:

<a click.capture="calledFirst()"
  click.trigger="calledSecond()"
  click.delegate="calledThird()"></a>

But I don't know if you really need to mess your view up like that.

There is another approach:

<a click.delegate="(first() || 1) && (second() || 1) && (third())"></a>

Notice the || 1, it helps ensure the right hand side of && always evaluated

like image 33
bigopon Avatar answered Feb 26 '23 22:02

bigopon