1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    86
    Vote Rating
    4
    karazy is on a distinguished road

      0  

    Default Answered: Prevent tabchange

    Answered: Prevent tabchange


    Hi,

    I'm looking for a way to prevent a tab change.
    I tried to hook into tabchange event but it won't fire.
    Is it possible to prevent the change by using tabchange?
    What am I missing?

    Code:
    Ext.application({
        launch : function() {
            
    var panel = Ext.create('Ext.TabPanel', {
        fullscreen : true,
        tabBarPosition: 'bottom',
        config: {
            tabBar : {
                tabchange : {
                    activate:  function(container, newTab, oldOTab, opts) {
                    alert('active');
                    }
                }
            }
        },
            items : [ 
            {
                docked : 'top',
                xtype : 'toolbar',
                itemId: 'topBar',
                title : 'title',
                items : [ {
                    xtype : 'button',
                    itemId : 'backBt',
                    text : 'back',
                    ui : 'back'
                } ]
            },         
            {
                xtype: 'carousel',
                itemId: 'carouselPanel',
                title: 'Home',
                iconCls: 'home',
                layout : {
                    type: 'card'
                },
    
    
                items: [ {
                    xtype: 'panel',
                    itemId: 'carousel1',
                    html: 'carousel1',
                    
                }, 
                {
                    xtype: 'panel',
                    itemId : 'carousel2',
                    html: 'carousel2',
                    
                }                    
                ] 
                
            },
            {
                xtype: 'panel',
                title: 'User',
                iconCls: 'user',
                html: 'User Tab',
                //hidden : true
               }
            ]
            
        
    });
        }
    });

  2. You will need to listen for activeitemchange on the tabpanel and return false.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Answers
    3462
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You will need to listen for activeitemchange on the tabpanel and return false.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    86
    Vote Rating
    4
    karazy is on a distinguished road

      0  

    Default


    Thx. It works. Here is my solution.
    In my controllers init -> control function I react to the itemchange:

    Code:
      myview : {
         			activeitemchange : function(container, value, oldValue, opts) {
        				console.log('tab change');
        				var status = true;
        				if(value.getItemId() === 'mytab') {
        					status = this.getApplication().getController('Order').refreshCart();
        				}
        				
        				if(status === false) {
        					    this.getMyView().setActiveItem(oldValue);					
        				}
        				
        				return status;
        			}
        		}

  5. #4
    Sencha Premium Member
    Join Date
    May 2012
    Location
    India
    Posts
    6
    Vote Rating
    0
    rejjy1980 is on a distinguished road

      0  

    Default


    Hi,

    I am also performing one check on activeitemchange event. If the check condition returns false the current tab should remain intact otherwise the selected tab contents should get displayed. In my controller I am writing:

    Code:
    onModuleChange: function(tabpanel, newModule, previousModule){
            
        if(newModule.getItemId() === 'myModuleId'){
            if(myClass.checkMyCondition()){
                return true;
            } else {
                return false;
            }
        }
    }

    I see that when myCheckCondition() returns false the activeItem in tabpanel object does not change, content of tabpanel does not change but the highlight of the button on tab bar changes. Please tell me if I am doing something wrong or something extra needs to be done.

    Regards,
    Rajat Srivastava

  6. #5
    Sencha Premium Member
    Join Date
    Aug 2013
    Posts
    12
    Vote Rating
    0
    shopeel is on a distinguished road

      0  

    Default


    rejjy1980: did you ever solve this issue? I'm experiencing the same behaviour.

  7. #6
    Sencha Premium Member
    Join Date
    May 2012
    Location
    India
    Posts
    6
    Vote Rating
    0
    rejjy1980 is on a distinguished road

      0  

    Default


    Hi,

    Please try this code. It worked for me

    Code:
    onModuleChange: function(tabpanel, newModule, previousModule){
        var myTabBarActiveTab = tabpanel.getTabBar().getActiveTab();    
        if(newModule.getItemId() === 'myModuleId'){
            if(myClass.checkMyCondition()){
                return true;
            } else {
                return false;
         tabpanel.getTabBar().setActiveTab(myTabBarActiveTab);
            }
        }
    }

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi