Drawing a set of circle with RaphaelJS library.
For each circle I want to create an onclick
function that passes a variable, but in this function my variable is undefined.
What is the problem?
This is my code:
//children is an array such as [1,2,4[5,6,7]]
for (var i = 0; i < children.length; i++) {
var array = children;
alert("ARRAY[0]===" + array[0])
var st = space2Draw.set();
st.push(space2Draw.circle(xChildren, yChildren, 20).click(function (array) {
//array[i] is undefined
alert("ARRAY[i]===" + array[i]);
//retrive(array[i]);
}),
LineRoot(xRadice, yRadice, xChildren, yChildren, space2Draw));
space2Draw.text(xChildren, yChildren, children[i]).attr({
fill: "white"
});
st.attr({
fill: "red"
});
xChildren += 50;
}