PDA

View Full Version : Handling functions in a TabPanel



flyingmachete
18 Jan 2011, 9:28 AM
Hi,

A newbie to Sencha Touch, pretty impressive framework so far but wish there was more documentation.

Was wondering how to call a function for a tab item in a TabPanel?

Should I be using the 'handler:' in the tab item or call a function outside of the TabPanel?

Thanks in advance,

Cheers,

tmanderson
18 Jan 2011, 9:56 AM
There are many ways to go about this, depending on the actual item within the TabPanel. If all you're adding is a button, the config object takes a parameter 'handler' which you can give a value of an anonymous function, or a reference to a function defined elsewhere.

http://dev.sencha.com/deploy/touch/docs/?class=Ext.Button (go to the 'handler' config parameter)

If you're adding a larger component (such as a panel) that requires more specific events, you can give the config object the parameter 'listeners', which you can assign another object which contains all of your specified events and handlers.

http://dev.sencha.com/deploy/touch/docs/?class=Ext.Component (go to 'listeners' config parameter)

flyingmachete
18 Jan 2011, 11:06 AM
Thanks for that, will check out the links.

lots to read it seems...........

Jeff Blake
18 Jan 2011, 3:50 PM
Im curious about this too...
TabPanels are not buttons. The content is embedded in the panel item. However.... this is not an MVC way of doing things. TabPanels should also have a "button-like" function where they can handle a function call (ie Dispatch)

Basically, an Ext.Button that looks like a Ext.TabPanel item. How?