2015-05-24 58 views
1

我有一個組。該組包含text,arcimage。在mouseenter我想添加stropPropagation的事件。 (因爲每次在文本事件觸發鼠標鼠標。)d3.js - image`mouseenter` stopPropagation拋出錯誤

所以我加了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); 
}) 

回答

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); 
    })