【发布时间】:2017-04-21 14:37:59
【问题描述】:
我有一个ListView 有点像这样:
<ListView>
<Templates>
<ItemTemplate name="example">
<View id="wrapper" onClick="onClickExampleButton">
<Label>Click Me</Label>
</View>
</ItemTemplate>
</Templates>
<ListSection id="ls">
<ListItem template="example"></ListItem>
<ListItem template="example"></ListItem>
<ListItem template="example"></ListItem>
</ListSection>
</ListView>
我想防止双击onClickExampleButton函数。
到目前为止,在控制器中我有这样的代码:
function onClickExampleButton(e) {
var item = $.ls.getItemAt(e.itemIndex);
// TODO: I want to disable the onClick eventListener here
someLongAsyncFuncToServer(function() {
// TODO: I want to re-enable the onClick eventListener here
})
}
通常删除事件侦听器就像
一样简单$.objId.removeEventListener(onClickExampleButton)
并重新添加它很简单:
$.objId.addEventListener(onClickExampleButton)
但是,我不确定如何在 ListItem 上实现这一目标
【问题讨论】:
标签: titanium appcelerator appcelerator-titanium titanium-alloy appcelerator-alloy