I get null on
view.children[0]
The view is a Titanium.UI.View-object and has just one child Titanium.UI.ImageView-object that need to access. How do I fix this?
I have had a look at How to query the child views of a parent view using Titanium? but it doesn't work for me. I found this, http://developer.appcelerator.com/question/31361/how-to-access-child-view-of-a-tableview-row , it could be a reason for my problem, any clue if this bug has been fixed?
Here is the more detailed code.
function (parentView, id, leftMargin) {
var cellImageView = cellImageView = Titanium.UI.createImageView({
url: imageUrl
});
var cellView = Ti.UI.createView({
id: id,
left: leftMargin,
parent: parentView
});
cellView.addEventListener('click', function (e) {
Titanium.API.info("you clicked1:" + e.source.id);
OnNumClick(e.source, e.source.parent);
});
cellView.add(cellImageView);
return cellView;
}
OnNumClick = function (cellViewObj) {
Titanium.API.info("cellViewObj:" + cellViewObj);
Titanium.API.info("cellViewObj.children:" + cellViewObj.children);
};
result: [INFO] [7,10537] cellViewObj:ti.modules.titanium.ui.ViewProxy@437ba5a8 [INFO] [15,10628] cellViewObj.children:null
My bad, I upgraded from Titanium SDK 1.2 to 1.6 (for some reason my setup was not working with 1.6 earlier), and it finally worked. Thanks for your help Muhammad.