【发布时间】:2013-04-05 16:43:35
【问题描述】:
我有多个饼图,我将它们放在一个数组中:
var pie_array = new Array();
创建饼图,如:
for loop{
pie = r.piechart(48+i*120,40,30,[100],
{
colors: ["white"],
maxSlices: 1
});
}
现在我正在为每个饼图添加点击事件:
$.each(pie_array, function(i, p){
$(p).click(function(){
alert(p);
});
});
但是当我单击饼图时无法触发事件...有什么解决方案吗?
可能的重复: How to add jquery click event to gRaphael graphics?
和
how can i add click evet to my rapahel pie chart?
但没有一个解决方案有效
我什至用过:
//below one says click event on unknown element..I printed p and it raphael set
$.each(pie_array, function(i, p){
p.click(function(){
alert(p);
});
});
and
$.each(pie_array, function(i, p){
p.node.oclick = function(){
alert(p);
};
});
但没有进展
【问题讨论】:
-
你能把你的解决方案分享给有同样问题的其他人吗?
-
@Chris:你知道要检索饼图的颜色、描边、半径等属性吗
-
是肯定的:是肯定的 $.each(pie_array, function(i) { this.click(function () { alert("hello"); }); }); jsfiddle.net/zFCur
标签: javascript jquery raphael pie-chart