Lui*_*uis 5 javascript ractivejs
可以说我有以下代码:
模板
<a on-click='myfunc' href="#">Activate!</button>
Run Code Online (Sandbox Code Playgroud)
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?
});
Run Code Online (Sandbox Code Playgroud)
如何从javascript代码中阻止来自href的下一个单击事件?我试过event.preventDefault(); 但该对象没有'preventDefault'方法
Ste*_*mas 11
来自文档:
event.original.preventDefault()
Run Code Online (Sandbox Code Playgroud)
正如您所注意到的,代理事件是自定义Ractive事件; 但是,该.original属性可让您访问"真实"事件.