html:
<div id='container'></div>
<script id='tpl' type='text/ractive'>
< h1 > Tooltip decorator < /h1>
<div onclick="say_hi()">
This text contains
<span id="decorated" decorator='tooltip:A tooltip is a blah blah...'>tooltips</span > < /div>
</script>
的javascript:
say_hi = function () {
alert(this.event.target.id)
}
var tooltipDecorator = function (node, content) {
var tooltip, click;
click = function () {
tooltip = document.createElement('p');
tooltip.className = 'ractive-tooltip';
tooltip.textContent = content;
node.parentNode.insertBefore(tooltip, node);
};
node.addEventListener('click', click, false);
return {
teardown: function () {}
}
};
Ractive.decorators.tooltip = tooltipDecorator;
ractive = new Ractive({
el: 'container',
template: '#tpl'
});
文档建议通过返回“假”来阻止事件冒泡。来自处理程序,作为文档中的工具提示示例。但是,通过捕获父元素上的事件,可以看出事件实际上正在传播(单击单词&#34;工具提示&#34;来自父div的警报表示它正在捕获点击)
我误解了什么?