0
votes

I have an Appcelerator Titanium app to do, i have a Ti.UI.ListView with a view inside (view_one.xml):

...
<ListView onItemclick="getEvaluation" id="myLisview" defaultItemTemplate="templateLm" bottom="0" top="10" onItemclick="changePage" backgroundColor="white">
    <Templates>
        <Require id="lm_items" src="common/templateLm"/>
    </Templates>  
</ListView>
...

in common/templateLm :

<Alloy>
    <ItemTemplate name="templatePageMission">
        <View bindId="evaluate" height="10dp">
            <Label text="evaluate"></Label>
        </View>
        <View bindId="stars" height="15dp"/>
    </ItemTemplate>
</Alloy>

in view_one.js :

function getEvaluation(e){
    switch(e.bindId){
        case 'evaluate':
            var item = e.section.getItemAt(e.itemIndex);
            console.log(item) // <= this is empty ????
            item.stars.backgroundColor = "red";
        break;
    }
}

and when click on the evaluate view I finally got: undefined is not an object (evaluating item.stars.backgroundColor)

If anyone can help, this is great, anyway thanks for this great community.

1

1 Answers

0
votes

You have assigned the itemclick event twice:

onItemclick="changePage" 

and

onItemclick="getEvaluation"

So if you just use the latter one, it should catch the controller function correctly and the item should be updated correctly, since your controller code looks valid.