d3.js - 图像`mouseenter` stopPropagation throw错误

时间:2015-05-24 06:05:04

标签: javascript jquery d3.js

我有一个小组。该论坛包含textarcimage。在mouseenter上,我想将stropPropagation添加到活动中。 (因为每次鼠标鼠标都在文本事件上触发。)

所以我添加了d3.event.sourceEvent.stopPropagation();方法。但它会引发错误Uncaught TypeError: Cannot read property 'stopPropagation' of undefined这里有什么问题?

代码:

d3.selectAll('.subAppGroupDetail image')
    .on('mouseenter', function (e) {
        d3.event.sourceEvent.stopPropagation();
        $('.quickView').show(500);
    })
    .on('mouseleave', function (e) {
    d3.event.sourceEvent.stopPropagation();
    $('.quickView').hide(100);
})

1 个答案:

答案 0 :(得分:0)

使用这样的代码:

  d3.selectAll('.subAppGroupDetail image')
   .on('mouseover', function (e) {
                d3.event.stopPropagation();
                $('.quickView').show(500);
   })
  .on('mouseout', function (e) {
           d3.event.stopPropagation();
           $('.quickView').hide(100);
  })