I want to implement the following :
BUT
So far I've tried the following:
<span {{action 'collapsePanel'}}>
{{#link-to 'otherRoute'}}
Some text
{{/link-to}}
</span>
I was hoping to override the default link-to behaviour by enclosing it in a clickable span but to no avail: now when I click on the link text, I am redirected to the new route and the click action itself never happens.
Is it possible to implement something like is using EmberJS or even plain JS tweaks?
Thanks!
put the span
inside and use a closure action:
{{#link-to 'otherRoute'}}
<span onclick={{action 'collapsePanel'}}>
Some text
</span>
{{/link-to}}
then you can call preventDefault
and return false:
collapsePanel(event) {
event.preventDefault();
return false;
}
this should prevent the event from bubbeling up to the link-to
.
Okay guys, I solved this thanks to a colleague. This snippet is working exactly as I intended:
{{#link-to "otherRoute"}}
<span {{action "collapsePanel" bubbles=false}}>
Some text
</span>
{{/link-to}}
The key was to set "bubbles=false", which prevents the action from taking over the link behaviour but still allows a click to trigger it.
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