Javascript 流星无法识别svg事件(鼠标向下)

Javascript 流星无法识别svg事件(鼠标向下),javascript,d3.js,svg,meteor,Javascript,D3.js,Svg,Meteor,我正在尝试使用d3包和meteor创建一个工作流图。可以通过单击页面来添加节点,并且可以从一个节点到另一个节点绘制边。然而,当我点击页面时,meteor无法识别mousedown事件。以下是我在事件处理程序中使用的代码: Template.graph.events({ 'mousedown svg': function (event,tmpl) { d3.event.preventDefault(); console.log("mousedown"); svg

我正在尝试使用d3包和meteor创建一个工作流图。可以通过单击页面来添加节点,并且可以从一个节点到另一个节点绘制边。然而,当我点击页面时,meteor无法识别mousedown事件。以下是我在事件处理程序中使用的代码:

Template.graph.events({ 
  'mousedown svg': function (event,tmpl) {
     d3.event.preventDefault();
     console.log("mousedown");
     svg.classed('active', true);
     if(d3.event.ctrlKey || mousedown_node || mousedown_link) return;
     var point = d3.mouse(this),
     node = {id: ++lastNodeId, reflexive: false};
     node.x = point[0];
     node.y = point[1];
     nodes.push(node);
     restart();
  }
});
下面是我如何设置svg的:

var width  = 800,
height = 300,
colors = d3.scale.category10();
var svg = d3.select('body')
.append('svg')
.attr('width', width)
.attr('height', height);
我尝试过使用其他解决方案,如(上面的函数是mousedown):

但是,我遇到了一些错误,例如“无法读取null的默认属性”。我的假设是流星并没有储存这一事件。我尝试使用另一个变量来存储事件,并对该变量运行操作,但没有效果。 例如:

svg.on('mousedown',function(event){
    var evt=event;
    mousedown(event);
});

如何让meteor识别svg上的mousedown事件?

您确定这是meteor问题而不是svg问题吗?D3事件不是真正的普通Javascript事件,您不能为它们混合处理程序。在本例中,我将使用D3事件处理程序。我尝试使用.on方法,但最终出现相同的错误
svg.on('mousedown',function(event){
    var evt=event;
    mousedown(event);
});