2

我有一个 jqplot 图表作为 Backbone.js 视图的一部分。图表及其数据都加载正常,但鼠标突出显示并单击图表似乎没有注册。它在 jqplot 示例中运行良好。只有当我将它添加到我的 Backbone.js 框架时,它才会停止工作。

我尝试使用“jqplotDataHighlight”和“jqplotClick”,但它们都不会触发事件,但是“jqplotDataUnhighlight”工作正常。我无法弄清楚为什么一个有效而另一个无效。

//part of Backbone.js View....
        var l2 = [11, 9, 5, 12, 14];    
        var l3 = [4, 8, 5, 3, 6];    
        var l4 = [12, 6, 13, 11, 2]; 

        //this event never triggers
        this.$('#plot3').bind('jqplotDataHighlight',         
           function (ev, seriesIndex, pointIndex, data) { 
               alert('highlight');           
               $('#info1b').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);        
           }); 

           //unhighlight event work just as expected  
        this.$('#plot3').bind('jqplotDataUnhighlight',         
               function (ev) {
                    alert("this worked: unhighlight")            
                    $('#info1b').html('Nothing');        
        });

        //chart load fine, showing all data             
        this.$('#plot3').jqplot([l2, l3, l4],{       
              stackSeries: true,       
              showMarker: false,       
              seriesDefaults: {           
                  fill: true       
              },       
              axes: {           
                 xaxis: {               
                      renderer: $.jqplot.CategoryAxisRenderer,               
                      ticks: ["Mon", "Tue", "Wed", "Thr", "Fri"]           
                 }       
              }    
          });
    });
4

1 回答 1

2

好吧,经过数小时的调试,我将回答我自己的问题。这将有望帮助一些像我一样犯错误的可怜的傻瓜。

在我的测试过程中,我添加了所有的 jqplot 插件,我终于发现移动插件覆盖了一些主要的 jqplot 事件处理程序,例如导致问题的 onClich。我删除了移动插件,一切都像一个魅力。

于 2012-12-15T00:58:48.573 回答