如何使用Meteor在SVG上添加事件?

时间:2017-05-17 09:08:20

标签: javascript jquery events meteor svg

我有一个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

enter image description here

我的目标是在点击元素时打印<text>的内容。

你可以帮我解决这个问题,因为我正在努力尝试并尝试......

1 个答案:

答案 0 :(得分:0)

最后我了解到我们无法使用public interface LimitRepository extends JpaRepository<CLimit, Long> { @Transactional @Modifying @Query("delete from CLimit l where l.trader.id =:#{#trader.id}") void deleteLimitsByTrader(@Param("trader") CTrader trader); } 的事件,因此我使用w3lib.encoding.html_to_unicode

相关问题