Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8354401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:32:15+00:00 2026-06-09T09:32:15+00:00

Attached is a my controller file .. i basically want to switch views ..

  • 0

Attached is a my controller file .. i basically want to switch views .. adding and removing a panel in a container with 2 buttons .. in the method for home and popular button i am using Ext.create again and again wouldnt that overload my application becoz iam not destroying my views iam adding and removing them .. My main question is how can i create global var ‘s for this situation like i create var homepanel = Ext.create just once and then i can reuse that var when i want to remove or add it from my mainContainer.. need serious guidance on this .. searched the whole documention but i dont have any clue about it

Ext.define('app.controller.MainController', {
extend: 'Ext.app.Controller',

config: {
    refs: {
        homeBtn: '#homeBtn',
        popularBtn: '#popularBtn',

        homePanel: '#homePanel',
        mainContainer: '#mainContainer'
    },
    control: {
        homeBtn:{
            tap: 'homeBtnAction'
        },
        popularBtn:{
            tap: 'popularBtnAction'
        }
    }
},


launch: function(app) {
    this.callParent(arguments);

    console.log("main launched");

    var mainCont = this.getMainContainer();
    var homepanel = Ext.create('app.view.Home.HomePanel');

    mainCont.add(homepanel);

    console.log("homePanelAdded");
},

homeBtnAction: function(){
    console.log("home page called");

    var mainCont = this.getMainContainer();
    var homepanel = Ext.create('app.view.Home.HomePanel');
    var popularpanel = Ext.create('app.view.Popular.PopularPanel');

    mainCont.remove(popularpanel);
    mainCont.add(homepanel);
},

popularBtnAction: function(){
    console.log("popular page called");

    var mainCont = this.getMainContainer();
    var homepanel = Ext.create('app.view.Home.HomePanel');
    var popularpanel = Ext.create('app.view.Popular.PopularPanel');

    mainCont.remove(homepanel);
    mainCont.add(popularpanel);
}
});

NOTE: Iam using Ext.define to create my views and using MVC structure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:32:17+00:00Added an answer on June 9, 2026 at 9:32 am

    Use this,

    var homepanel = this.getHomePanel() || Ext.create('app.view.Home.HomePanel');
    

    if this.getHomePanel() does not return anything it’ll create the panel for you. After that you’ll use the already created panel.

    Other note, unless you are manipulating the buttons in some manner there is no need to give them an id or a ref.

    Set up your button in your view like so

    {
    xtype : 'button',
    text : 'Home Panel',
    action : 'goHome'
    }
    

    then in the control section of your controller use this

    'button[action=goHome] : 
     {
      tap: 'homeBtnAction'
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm struggling with paperclip and adding the attached images to albums. Should I be
Using Rails 3.2.1 I created a simple controller called Home using the command: rails
I have a pdf file attachment saved in the cloud. The file is attached
I use paperclip to add a file to my model. I want to use
I have a model that has an image attached to it that I want
I want to make layout like the attached image but the problem is when
The problem is that controller doesn't see template I want to use: [etl_admin] $
(see attached jsfiddle, screenshots; running browsers on Ubuntu 11.10) There seems to be some
I have a taxonomy attached with my content type. While creating node of that
I found this script attached to a modified index page. This looks like some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.