[TIMOB-19327] ListView - template event handler not working if using "var" declaratoin
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 4.1.1 |
Fix Version/s | n/a |
Components | Android, iOS |
Labels | n/a |
Reporter | Shawn Lan |
Assignee | Unknown |
Created | 2015-07-31T19:10:34.000+0000 |
Updated | 2018-02-28T19:55:14.000+0000 |
Description
Create a default Alloy project with the following:
index.xml
<Alloy>
<Window>
<ListView defaultItemTemplate="template" onItemclick="list1Click" backgroundColor="white">
<Templates>
<ItemTemplate name="template">
<View onLongpress="handler">
<Label bindId="title" />
</View>
</ItemTemplate>
</Templates>
<ListSection>
<ListItem title:text="TEST ITEM 1" />
<ListItem title:text="TEST ITEM 2" />
</ListSection>
</ListView>
</Window>
</Alloy>
index.js
var handler = function() {
Ti.API.info("longpressed");
};
var list1Click = function(){
Ti.API.info("item clicked");
};
$.index.open();
On iOS, the function "handler" is simply not working. On Android, it'll throw exception saying event handler undefined. However, itemclick event works fine.
If we declare function "handler" like the following, then it works fine on both iOS and Android.
function handler() {
Ti.API.info("longpressed");
}
var list1Click = function(){
Ti.API.info("item clicked");
};
$.index.open();
So event handler for template element can't be declared using "var." This inconsistency could cause confusion to developer.
No comments