【发布时间】:2017-10-16 15:35:06
【问题描述】:
我有一个 SVG,我想在上面添加一个事件监听器。
我的结构如下:
<template name="dataGraph">
<div style="height: 100%;" class="right_col" role="main">
<div id="logoObject">
<object id="svg_compose" type="image/svg+xml" data="output.svg">Your browser does not support SVGs</object>
</div>
</div>
</template>
在我的 JavaScript 中我做到了:
Template.dataGraph.onCreated(function dataGraphOnCreated() {
});
Template.dataGraph.onRendered(function dataGraphOnRendered() {
$(document).on('click','svg',function(){
alert('You clicked me svg');
});
$(document).on('click','#svg_compose',function(){
alert('You clicked me svg_compose');
});
$(document).on('click','#logoObject',function(){
alert('You clicked me logoObject');
});
});
Template.dataGraph.events({
'click #svg_compose': function(e){
console.log("we are in the svg element");
}
});
唯一工作的听众是#logoObject之一
我的目标是当我们点击元素时打印<text>的内容。
你能帮我搞定吗,因为我一直在尝试,在尝试,在尝试......
【问题讨论】:
标签: javascript jquery events meteor svg