-
-
Notifications
You must be signed in to change notification settings - Fork 613
Open
Description
I'm trying to prevent a link with a route-href attribute from navigating to the new URL.
When I configure the router to use hashChange instead of pushState it works fine. But if I switch to pushState preventDefault() does nothing:
import {inject} from 'aurelia-framework';
@inject(Element)
export class PreventHrefCustomAttribute {
constructor (el) {
this.el = el;
this.onClick = e => {
e.preventDefault(); // This only works when pushState: false, hashChange: true
alert('The href should not be followed');
};
}
attached () {
this.el.addEventListener('click', this.onClick);
}
detached () {
this.el.removeEventListener('click', this.onClick);
}
}<a route-href="route: item; params.bind: {id: item.id}" prevent-href>${item.name}</a>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels