jqplot不会在backbone.js视图中触发“jqplotDataClick”事件

时间:2023-01-18 20:05:47

I have a jqplot chart as part of a Backbone.js view. The chart and it's data all load fine, but mouse highlighting and click on the chart don't seem to be registered. It works fine in the jqplot examples. It is only when I add it to my Backbone.js framework that it stops working.

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

I have tried using "jqplotDataHighlight" and "jqplotClick" and neither of them trigger an event, however "jqplotDataUnhighlight" works fine. I can't figure out why one works and the other don't.

我尝试过使用“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"]           
                 }       
              }    
          });
    });

1 个解决方案

#1


1  

Well I will answer my own question after hours of debugging. Which will hopefully help some poor fool who makes mistakes like I do.

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

During my testing I had added in all of the jqplot pluggins and I finally found out the the mobile pluggin overrides some of the main jqplot event handlers like onClich which was causing the problems. I remove the mobile pluggin and everything worked like a charm.

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

#1


1  

Well I will answer my own question after hours of debugging. Which will hopefully help some poor fool who makes mistakes like I do.

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

During my testing I had added in all of the jqplot pluggins and I finally found out the the mobile pluggin overrides some of the main jqplot event handlers like onClich which was causing the problems. I remove the mobile pluggin and everything worked like a charm.

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