Skip to content

Instantly share code, notes, and snippets.

@tdtsh
Created April 30, 2014 00:40
Show Gist options
  • Save tdtsh/a119a2484b4c545b896c to your computer and use it in GitHub Desktop.
Save tdtsh/a119a2484b4c545b896c to your computer and use it in GitHub Desktop.
Titanium Alloy での ListView のイベントハンドリング
Alloyでのclickイベント制御の書き方の一例です。
```/app/controller/sample.js
var data = [];
...
data.push({
template: "MyItemTemplate",
tags: { text : "hoge" },
....
$.sectionA.setItems(data);
...
function onItemClick(e) {
var item = e.section.getItemAt(e.itemIndex);
if (e.bindId === "tags") {
Ti.API.info("This is hoge: " + item.labelA.text);
handleTagClickEvent();
}
}
```
```/app/view/sample.xml
<Alloy>
<Window>
<ListView id="listA" onItemclick="onItemClick">
<Templates>
<ItemTemplate name="MyItemTemplate">
<Label id="labelA" bindId="tags"/>
...
</Templates>
<ListSection id="sectionA" />
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment