在Ext.List上触发itemtap事件

时间:2012-04-04 11:57:37

标签: list events sencha-touch

我已经定义了一个sencha List,如下所示

Ext.List({
                    itemTpl: '<div class={filterClass}></div>{filterType}',
                    id: 'sFilter',
                    width: 200,
                    cls: 'sFilter',
                    grouped: false,
                    indexBar: false,
                    store: store,
                    listeners: {
                        itemtap: function (me, index, item, e) {
                            var selectedRecord = me.store.getAt(index);
                            var filterTag = selectedRecord.data.filterTag;
                            if (filterTag !== searchResultTag.Everything) {
                                var filteredResults = filterResults(filterTag, allResults);
                                //some more code
                            } else {
                                //some more code
                            }
                        }
                    }
                });

列表中的项目是动态添加的,它们没有“id”。 我想在上面的列表中触发(第一项)itemtap事件。我怎么能这样做?

2 个答案:

答案 0 :(得分:0)

这应该允许您抓取所选记录并触发该点击事件

  listeners: {
            itemtap: function (me, record, index, item, e) {
                var selectedRecord = index.data.filterType;
                var rec=record;

                if(rec===0){
                    alert('This is the first record');
                }else{
                    alert('This is not the first record')
                }
                       alert(selectedRecord);


        }
    }

答案 1 :(得分:0)

 listeners: {
        itemtap: function (me, index, item,record,e) {


            if(index==0){
                alert('This is the first record');
            }else{
                alert('This is not the first record')
            }
                   alert(selectedRecord);


    }
}

这可能会对你有所帮助