Results 1 to 2 of 2

Thread: how to use the setActiveItem method of Cardlayout??????

  1. #1

    Default how to use the setActiveItem method of Cardlayout??????

    Here is my code:
    Code:
    App.View.Test = Ext.extend(Ext.Panel,{
    	
    	layout:'card',
    	fullscreen:true,
    	activeItem:0,
    	initComponent: function() {
    		Ext.apply(this,{
    			items:[
    				{
    					xtype:'button',
    					handler:this.ttt
    				},
    				{
    					html:'111'
    				},
    				{
    					html:'222'
    				}
    			
    			]
    		
    		});
    		App.View.Test.superclass.initComponent.call(this);
    	},
    	
    	ttt:function(){
    		this.setActiveItem(2,'fade');
    		
    	}
    
    });
    It doesn't work,

    console said that"TypeError: Object [object Object] has no method 'setActiveItem'"

    why?????please help me !!!

  2. #2

    Default

    bluefox617,

    The scope of "this" is your button and not your panel. To correct that, setup your button in the items array like this:

    {
    xtype:'button',
    handler:this.ttt,
    scope: this
    }

    That way you'll be passing in the scope of the panel, and within your handler "this" will refer to the panel and not the button. If you ever need access to the button, create the handler function like this:

    function ttt(b,e){
    // Code here
    }

    "b" will be your button that called the handler and "e" will be an event object.

Similar Threads

  1. Replies: 4
    Last Post: 11 Mar 2014, 7:23 AM
  2. CardLayout and setActiveItem
    By jmtulloss in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 28 Mar 2012, 10:44 PM
  3. Can anyone help with setActiveItem method?
    By iphoneguy in forum Sencha Touch 1.x: Discussion
    Replies: 23
    Last Post: 2 Mar 2011, 9:30 AM
  4. Replies: 0
    Last Post: 30 Sep 2010, 9:41 AM
  5. CardLayout.setActiveItem not working
    By dVyper in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 8 Dec 2008, 1:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •