简体   繁体   中英

fire the 'itemtap' event dynamically to a list item

When using Sencha Touch 2, I want to fire the itemtap event dynamically to an item of a list ( Ext.List ), I did it in this way:

Ext.getCmp(LIST_ID).container.fireEvent('itemtap', null, null, ITEM_INDEX,
    new Event('itemtap'));

Running this line, the itemtap event was fired on the ITEM_INDEX of the LIST_ID . Now when updating my framework to sencha touch 2.1 this way is not working anymore...

Is their another way to fire this event dynamically?

I use this syntax : fireEvent('itemtap', index, node). To get the node object, you should use getNode() or getAt() .

// For example, to tap the first item
// sencha 1.1
Ext.getCmp(LIST_ID).fireEvent('itemtap', 0, Ext.getCmp(LIST_ID).getNode(0)); 
// sencha 2.1
Ext.getCmp(LIST_ID).fireEvent('itemtap', 0, Ext.getCmp(LIST_ID).getAt(0)); 

Regards

a working example is

listobj.fireEvent('itemtap',listobj,indexofListInt);

In general if you have an event (in st api documentation) defined as: itemtap( this, index, target, record, e, eOpts )

to fire an event you must:

obj.fireEvent('eventname',this, index, target, record, e, eOpts )

the args after 'eventname' are in the exact right order as in the api doc for the event signature!

that's all folks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM