问题
I want to add a listener which listens to updatedata event in my custom component.
I have several ways to do it, but don't know which one is correct:
inside config
config:{ updatedata:"dataUpdated" }, dataUpdated: function() { ......... }
2.
config:{
listeners:{
updatedata: function(thisComponent, newData, eOpts){
..............
}
}
}
Also, do I need to call something like: me.updatedata() within the listener function?
Please correct me if something wrong in my code.
Thank you.
回答1:
You would wrap listeners
in config
when executing Ext.define
. During Ext.create
, or in items
you would place them at the root of passed object (not wrapped in config
)
Events are explained in details in Sencha Touch Event Guide
来源:https://stackoverflow.com/questions/24051274/where-and-how-to-write-updatedata-event-in-the-correct-way