2012-12-14 37 views
2

我有一個jqplot圖表作爲Backbone.js視圖的一部分。圖表和它的數據都加載正常,但鼠標突出顯示並單擊圖表似乎沒有註冊。 它在jqplot示例中正常工作。只有當我將它添加到我的Backbone.js框架中時,它纔會停止工作。jqplot不會觸發backbone.js視圖中的「jqplotDataClick」事件

我一直在使用「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

那麼在經過幾個小時的調試後,我會回答我自己的問題。這將有希望幫助一些像我一樣犯錯誤的可憐的傻瓜。

在測試過程中,我添加了所有的jqplot插件,最後我發現移動插件覆蓋了一些主要的jqplot事件處理程序,如導致問題的onClich。我刪除了手機插件,一切都像魅力一樣。