Sencha Touch itemtap [英] Sencha Touch itemtap
问题描述
我有一个列表,其中sencha触摸显示在列表中的联系人。然后,当您单击列表中的名称时,它应向右滑动,并说Hello {contact name}!但是当它滑过现在它只是说你好!在第29行是动作发生的项目tap我相信问题在这里。我只是不知道如何格式化它正确。以下是我的源代码。
I have a list of contacts that sencha touch is displaying in a list. Then when you click a name in the list it should slide to the right and say Hello {contact name}! but when it slides over right now it just says Hello !on line 29 is where the action is happening for item tap i belive the problem is here. I just dont know how to format it correctly. Below is my source code.
ListDemo = new Ext.Application({
name: "ListDemo",
launch: function() {
ListDemo.detailPanel = new Ext.Panel({
id: 'detailpanel',
tpl: 'Hello, {firstName}!',
dockedItems: [
{
xtype: 'toolbar',
items: [{
text: 'back',
ui: 'back',
handler: function() {
ListDemo.Viewport.setActiveItem('disclosurelist', {type:'slide', direction:'right'});
}
}]
}
]
});
ListDemo.listPanel = new Ext.List({
id: 'disclosurelist',
store: ListDemo.ListStore,
itemTpl: '<div class="contact">{firstName} {lastName}</div>',
listeners:{
itemtap: function(record, index){
ListDemo.detailPanel.update(record.data);
ListDemo.Viewport.setActiveItem('detailpanel');
}
}
});
ListDemo.Viewport = new Ext.Panel ({
fullscreen: true,
layout: 'card',
cardSwitchAnimation: 'slide',
items: [ListDemo.listPanel, ListDemo.detailPanel]
});
}
});
推荐答案
传递给itemtap事件的第一个参数不是列出项目的记录,它是DataView本身。
The first argument passed to the itemtap event isn't the record of the List item tapped, it's the DataView itself.
从文档中
itemtap:(Ext.DataView this,Number index,Ext.Element item,
Ext.EventObject e)
点击节点时触发
itemtap : ( Ext.DataView this, Number index, Ext.Element item, Ext.EventObject e ) Fires when a node is tapped on
Listeners will be called with the following arguments:
this : Ext.DataView
The DataView object
index : Number
The index of the item that was tapped
item : Ext.Element
The item element
e : Ext.EventObject
The event object
您可以使用以下方式获取攻击记录:
You can grab the tapped record by using:
dataView.store.getAt(index); // where 'dataView' is 1st argument and 'index' the 2nd
这篇关于Sencha Touch itemtap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!