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)">
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.
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With