I am trying to add items to a dynamically created list section. My list and item templates are created with Alloy. I am creating the list sections with the following:
function createGroupObject(){
for (i=0; i<allStakeholderData.length; i++){
for (z=0; z<=stakeholderGroups; z++){
if (allStakeholderData[i].group !== stakeholderGroups[z]){
stakeholderGroups.push(allStakeholderData[i].group);
var stakeholderSections = Ti.UI.createListSection({
id: allStakeholderData[i].group,
headerTitle: allStakeholderData[i].group
});
$.allStakeholdersList.appendSection(stakeholderSections);
}
}
}
addStakeholdersToGroups();
}
I think that the problem is in here, because I never see the sections get added, but I don't know if that is due to the later error that I am getting.
I get the error trying to append an item to my sections:
function addStakeholdersToGroups(){
for(i=0; i<allStakeholderData.length; i++){
var thisTask = [],
thisGroup = allStakeholderData[i].group;
thisTask.push({
stakeholderName: {text:allStakeholderData[i].nameFirst + ' ' + allStakeholderData[i].lastName},
stakeholderEmail: {text:allStakeholderData[i].email},
stakeholderCompany: {text:allStakeholderData[i].company},
template: "allStakeholdersTemplate"
});
$.owner.appendItems(thisTask);
//$[thisGroup].appendItems(thisTask);
}
}
I have commented out the attempt to dynamically choose the correct section to append the item to, and used one that I know is the name of a group. It still gives me an error:
[ERROR] : Script Error { [ERROR] : column = 20; [ERROR] : line = 40; [ERROR] : message = "undefined is not an object (evaluating '$.owner.appendItems')";