Dom Element onclick (MooTools :: optionally)
- by Theofanis Pantelides
Consider the following example:
function async_callback(array1, array2, array3) {
// All arrays are equal length
for(var i = 0; i < array1.length; i++) {
var myElement = new Element('div', { 'id': 'dvMy' + i, 'events': { 'click': function() { SomeFunction(array1[i], array2[i], array3[i] } }});
$(document).appendChild(myElement);
}
}
Now when I click my element, I get a null value for all three arguments.
I even tried doing: myElement.onclick = SomeFunction; // but this won't allow arguments
I know I can create a string and use eval() and that does work, but I don't like eval().
Any ideas???
btw: This is a simple example to replicate the problem, and not actual code.