Q:

Listener to Tab Item Click in Sencha

In my application, I'm using a tab panel with 5 items in it.  Each item holds around 6 panels added in card layout.  When I'm at the last panel inside a tab item, I need to get back to the initial panel by clicking on the bottom tab panel (somewhat similar to a normal tab view controller in iOS).  I have came across some solutions I found here, but it seems to work only when I switch between the tabs.  In fact I want to listen to the click event on the same tab icon.  How can I do this? 

A:

I have worked on your problem.  I think this is exactly what you want.  Hope this helps.  If not so, please leave a comment. 
1).  View (MyTabPanel1.js)
    Ext.define('MyApp.view. MyTabPanel1', {
    extend: 'Ext.tab. Panel',
    config: {

            scrollable: 'vertical',
             items:
            [
                {
                   xtype: 'panel',
                   id:'cardpanel1',
                   title: 'Tab1',              
                   layout: 'card',
                        items: [
                            {  
                                html: "First Item",
                                items:
                                [
                                {
                                    xtype: 'button',
                                    text: 'Forward',
                                    handler: function() {
                                    Ext.getCmp('cardpanel1').setActiveItem(1);
                                    console.log('Going to Second Item');
                                    }
                                }
                                ]
                            },
                            {
                                html: "Second Item",
                                items:
                                [
                                {
                                    xtype: 'button',
                                    ui: 'confirm',
                                    text: 'Go back',
                                    handler: function() {
                                    Ext.getCmp('cardpanel1').setActiveItem(0);
                                    console.log('Going to First Item');
                                    }
                                }
                                ]
                            }

                        ]               

                },

                {
                    xtype: 'panel',
                    title: 'Tab2',
                    scrollable: true,
                    items: [
                        {
                            xtype: 'button',
                            margin: 10,
                            ui: 'action',
                            text: 'Tab2'
                        }

                    ]
                },
                {
                    xtype: 'panel',
                    title: 'Tab3',
                    scrollable: true,
                    items: [
                        {
                            xtype: 'button',
                            margin: 10,
                            ui: 'action',
                            text: 'Tab3'
                        }
                    ]
                }

            ]
        }

    });

2).  Controller (MainController.js)
    Ext.define('MyApp.controller. MainController', {
        extend: 'Ext.app. Controller',
        config: {
            control: {

                "tabpanel #ext-tab-1":{  //ext-tab-1 is the id for the 1st tab generated by Sencha
                   tap: 'ontap'
                }            
            }
        },

        ontap: function (){
        console.log('inside controller');
        Ext.getCmp('cardpanel1').setActiveItem(0);
        }

    });

