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

  • Home
  • SEARCH
  • 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 4060936
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:24:10+00:00 2026-05-20T15:24:10+00:00

I am using jQuery to create tabs. I put the javascript code in a

  • 0

I am using jQuery to create tabs. I put the javascript code in a separate file. tabset variable is used to reference the tab. Javascript has the following content:

$(document).ready(function() {
//add a tabset
var tabset = $("#tabset").tabs({
    /*add close button*/
    tabTemplate: "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
    /*cache tabs*/
    cache: true,
    /*immediately select a just added tab*/
    add: function(event, ui) {
        //alert(ui.panel.id);
        tabset.tabs('select', '#' + ui.panel.id);
    }
});

I could add another tab with the statement below. This works fine if I call this statement from this javascript.

tabset.tabs('add', url, nameToCheck);

I would like to add a new tab to the tabset called #tabset from another javascript file where I could not use tabset variable because it is out of scope.

I try to use jquery selector to find tabset and call add function but the tab is not added. Please check the statement below:

$('#tabset').tabs('add', 'url', 'newTab');

My question is: how to add another tab to existing tabset from any javascript file? How to select an existing tabset and to call an add function?

Best regards,
Javanus

  • 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-05-20T15:24:10+00:00Added an answer on May 20, 2026 at 3:24 pm

    Try to do this:

    $(document).ready(function() {
       $("#tabset").tabs({
        tabTemplate: yourtabtemplate,
        cache: true,
        add: function(event, ui) {
            // Change 'tabset' to 'this'
            this.tabs('select', '#' + ui.panel.id);
        }
    });
    

    And in the other JS file:

    var tabset = $('#tabset');
    tabset.tabs('add', url, nameToCheck);
    

    Or simply:

    $('#tabset').tabs('add', 'url', 'newTab');
    

    EDIT: the problem is that you probably are adding your first file before your second file. So, $('#tabset') doesn’t have tabs feature from JQueryUI and $('#tabset').tabs('add') is not working.

    Switch the order like this:

    file1.js:

    $(document).ready(function() {
       $("#tabset").tabs({
        tabTemplate: yourtabtemplate,
        cache: true,
        add: function(event, ui) {
            // Change 'tabset' to 'this'
            this.tabs('select', '#' + ui.panel.id);
        }
    });
    

    file2.js:

    $('#tabset').tabs('add', 'url', 'newTab');
    

    You index view:

    <script src="scripts/file1.js"></script>
    <script src="scripts/file2.js"></script>
    

    Check file order. Happy codding!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jQuery to create a load of tabs for a web application. I've
I'm using jquery.ui.tabs to create a carousel. On the same page is a superfish
I am using jquery tabs to load content from a remote file. I have
I am using jquery ui in several places to create ui elements like tabs,
I'm using a simple jQuery script for tabs: The JS: $(document).ready(function() { $(.tab-content).hide(); $(ul.tabs
I have created an interface using jQuery UI Tabs, however one of my requirements
I was using jQuery plugins to create a rounded corner for my <li> ,
I'm trying to create a simple toggling sidebar using jquery, where it expands and
I have this jQuery ajax navigation tabs plugin that I created using some help
I am using Jquery UI tabs, and have it set to toggle the opacity

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.