The task is the same as in this post: capture click on a link and prevent the browser's default behavior. The answer given there was this:
Template:
<a on-click='sayHello' href="#">Activate!</button>
JS:
ractive.on( 'sayHello', function ( event ) {
event.original.preventDefault();
alert( 'Hello world!' );
});
The problem is that the sayHello
event handler should not know about what the original event was. The whole point of proxying is that the event handler should not care about the type of the original event. For example, I change the link into a button, there's no more need for preventDefault
.
So, my question is how I can invoke preventDefault before or after firing the event proxy.
A nice solution would be to fire several event proxies in a row (if it was possible):
Template:
<a on-click='preventDefault;sayHello' href="#">Activate!</button>
Js:
ractive.on( 'preventDefault', function ( event ) {
event.original.preventDefault();
});
ractive.on( 'sayHello', function ( event ) {
alert( 'Hello world!' );
});
Is this possible somehow? Or is there some other nice solution?