Ractive.js preventDefault events on event proxies

爱⌒轻易说出口 提交于 2019-12-10 15:11:11

问题


Lets say I have the following code:

template

<a on-click='myfunc' href="#">Activate!</button>

javascript

var ractive = new Ractive({
  el: output,
  template: template
});

ractive.on( 'myfunc', function ( event ) {
  alert( 'Hello world!' );
  ?????? --> how to prevent the next click event from the a href?
});

How can I prevent the next click event from the a href, from the javascript code? I tried event.preventDefault(); but the object has no method 'preventDefault'


回答1:


From the docs:

event.original.preventDefault()

Proxy events are, as you've noticed, custom Ractive events; however, the .original property gets you access to the "real" event.



来源:https://stackoverflow.com/questions/19015586/ractive-js-preventdefault-events-on-event-proxies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!