简体   繁体   English

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

[英]jqplot not triggering“jqplotDataClick” event within backbone.js view

I have a jqplot chart as part of a Backbone.js view. 我有一个jqplot图表作为Backbone.js视图的一部分。 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. 在jqplot示例中,它工作正常。 It is only when I add it to my Backbone.js framework that it stops working. 只有将其添加到Backbone.js框架后,它才能停止工作。

I have tried using "jqplotDataHighlight" and "jqplotClick" and neither of them trigger an event, however "jqplotDataUnhighlight" works fine . 我尝试使用“ jqplotDataHighlight”和“ jqplotClick”,但它们都不触发事件, 但是“ jqplotDataUnhighlight”可以正常工作 I can't figure out why one works and the other don't. 我不知道为什么一个可行,而另一个却不可行。

//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"]           
                 }       
              }    
          });
    });

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. 在测试过程中,我添加了所有jqplot插件,最后我发现移动插件重写了一些主要的jqplot事件处理程序,例如onClich,这引起了问题。 I remove the mobile pluggin and everything worked like a charm. 我删除了移动插件,一切都像个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM