10 09/2014

flot stop propagation

最后更新: Wed Sep 10 2014 12:35:31 GMT+0800

Flot event is not the original event!So can not directly event.stopPropagation()

Just use jquery on click to stop it!

.on('click',function(e){
  //只能在这里 停止冒泡!!!
  e.stopPropagation();
  e.preventDefault();
})
var obj=$('#obj');
$(document).on('click',function(){
  console.error('clicked body')
  clickInfo.hide();
})
obj.bind("plotclick", function (e,pos,item) {
 if(item){
    str=data.legends[item.dataIndex]+' '+item.series.label +':'+item.datapoint[0]
    // console.log(str,pos.pageX)
    clickInfo.find('.t').text(str).show();
    clickInfo.css({
      left:pos.pageX+'px',
      top:pos.pageY+'px'
    });

  }
}).on('click',function(e){
  //只能在这里 停止冒泡!!!
  e.stopPropagation();
  e.preventDefault();
})