Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

LIstView item button to update model

$
0
0

In the example below I have a button on each listview item which when clicked I'd like it to update the model binded to that item. I can get the onClick event to work but can't work out how to get item data to then update the model. Is this even possible?

index.xml

<Alloy>
    <Window>
        <ListView id="list">
            <Templates>
                <Require src="itemTemplate"/>
            </Templates>
            <ListSection dataCollection="collection">
                <Require src="listItem"/>
            </ListSection>
        </ListView>
    </Window>
</Alloy>
itemTemplate.xml
<Alloy>
    <ItemTemplate name="user" height="70">
        <Button id="update" onClick="updatedUser" />
        <Label id="name" bindId="name"/>
    </ItemTemplate>
</Alloy>
listItem.xml
<Alloy>
    <ListItem template="user" name:text="{{name}}"/>
</Alloy>
itemTemplate.js
function updatedUser() {
    //change an attribute on the model and save
 
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>