Hi guys, I'm having a bit of a problem. I've got 9 image views (img1, img2, img3, etc) and I want to add a click event listener to all of them.
I've tried saving the function as a variable but somehow the e isn't associated with the imageview.
example code:
var img1 = Ti.UI.createImageView({ image:"sample.jpg" }); var listenerFunc = function(e){ Ti.API.info(e.image); }; img1.addEventListener('click',listenerFunc);The result of the above will be
undefined.
Any ideas guys?
1 Answer
Accepted Answer
If you test your code with:
img1.addEventListener('click',(e){ Ti.API.log(e); });you will see the content of e. The right property is
source.
Your Answer
Think you can help? Login to answer this question!