我有一个jqplot图表作为Backbone.js视图的一部分。图表和它的数据加载都很好,但鼠标高亮显示和点击图表似乎没有注册。它在jqplot示例中运行良好。只有当我把它添加到我的Backbone.js框架中时,它才会停止工作。
我尝试过使用"jqplotDataHighlight"one_answers"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"]
}
}
});
});
经过数小时的调试,我将回答自己的问题。这将有望帮助一些像我一样犯错的可怜的傻瓜。
在测试过程中,我添加了所有的jqplot插件,最终发现移动插件覆盖了一些主要的jqpot事件处理程序,如onClich,这是造成问题的原因。我拔下了移动插头,一切都很顺利。