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 7805227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:09:30+00:00 2026-06-02T02:09:30+00:00

I’m using Dojo ‘s Dijit Layout for generating content tab-panes similar to Dijit Theme

  • 0

I’m using Dojo‘s Dijit Layout for generating content tab-panes similar to Dijit Theme Tester Demo. All of the tabs here are closeable.

The issue is: when I close a tab it goes back to the first tab in the list instead of the previous tab (available next to it).

You can think of it like opening a new tab in Firefox or Chrome and try closing the last tab…. on closing tab, it changes the focus to the previous tab which is a predictable behavior for working with tabs. But with dijit.TabContainers, by default it goes back to the very first tab instead of previous one. This is a serious flaw when you consider the UI basics.

I have checked with dojo docs, but don’t found any hint on this. Any idea how to it?

  • 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-02T02:09:31+00:00Added an answer on June 2, 2026 at 2:09 am

    Ok so when the [X] button on the dijit.layout.ContentPane (tab) is clicked an event onClose is generated, the dijit.layout.TabContainer is listening to this event, so when this happens, it executes the callback closeChild() then the function removeChild() is executed, this last one is the one you should override.

    The tabContainer inherits this two functions from dijit.layout.StackContainer you should check the API documentation.

    So for being able to modify the default behavior of the closing tabs, you should override the default functionality, in the example below i do this. Read the comments for info on where to add your logic.

    E.g.

    <script>
        require([
            "dojo/parser",
    
            "dojo/_base/lang", //this is the one that has the extend function
            "dojo/topic", //this is needed inside the overrided function
    
            "dijit/layout/TabContainer",
            "dijit/layout/ContentPane", 
    
            "dojo/domReady!"
        ], function(Parser, lang, topic, tabContainer, contentPane){
            Parser.parse();
    
            // this will extend the tabContainer class and we will override the method in question
            lang.extend(tabContainer, {
    
                // this function, i copied it from the dijit.layout.StackContainer class
                removeChild: function(/*dijit._Widget*/ page){
    
                    // for this to work i had to add as first argument the string "startup"
                    this.inherited("startup", arguments);
    
                    if(this._started){
                        // also had to call the dojo.topic class in the require statement
                        topic.publish(this.id + "-removeChild", page);  
                    }
    
                    if(this._descendantsBeingDestroyed){ return; }
    
                    if(this.selectedChildWidget === page){
                        this.selectedChildWidget = undefined;
                        if(this._started){
                            var children = this.getChildren();
                            if(children.length){
    
                                // this is what you want to add your logic
                                // the var children (array) contains a list of all the tabs
                                // the index selects the tab starting from left to right 
                                // left most being the 0 index   
    
                                this.selectChild(children[0]);
                            }
                        }
                    }
    
                    if(this._started){
                        this.layout();
                    }
                }
            });
    
            // now you can use your modified tabContainer WALAAAAAAA!
            // from here on, normal programmatic tab creation
            var tc = new tabContainer({
                style: "height: 100%; width: 100%;",
            }, "tab-container-div-id");
    
            var cp1 = new contentPane({
                title: "First Tab",
                closable: true
            });
            tc.addChild(cp1);
    
            var cp2 = new contentPane({
                title: "Second Tab",
                closable: true
            });
            tc.addChild(cp2);
    
            var cp3 = new contentPane({
                title: "Third Tab",
                selected: true,
                closable: true
            });
            tc.addChild(cp3);
    
            tc.startup();
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

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.