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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:42:41+00:00 2026-05-16T05:42:41+00:00

I just made a script to empty the previously selected tab. It is working

  • 0

I just made a script to empty the previously selected tab. It is working fine when we switch from 1 to 2 to 3.

But it is not working when we switch from 3 to 2 to 1. Here is the script

var prevTab = 0;
jQuery("#tabs").tabs({ fx: { opacity: "toggle" },
cache: false,
show: function(event, ui) {
alert(prevTab);
         var prevTab = ui.index;
   jQuery("#ui-tabs-"+prevTab).empty();  //set the new previous tab index to the    current index
 }

});

Since I have a form in each tab I got a conflict, so I need to empty the content of the previous tab.

Thanks for your helping hand,
Gobi:)

  • 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-16T05:42:42+00:00Added an answer on May 16, 2026 at 5:42 am

    You’re creating a new local variable inside the callback function by doing var prevTab = ui.index. This way, the value is lost when you exit the function (and its scope). Use the existing prevTab instead of declaring a new instance and it should be fine

    var prevTab = 0;
    jQuery("#tabs").tabs({
        fx: { opacity: "toggle" },
        cache: false,
        show: function(event, ui) {
            alert(prevTab);
            prevTab = ui.index; //no var
            jQuery("#ui-tabs-"+prevTab).empty();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just made a register script from scratch, but I'm still going to improve
I just made a transaction go through but not sure where there is a
I'm getting started with making few redirect with .htaccess but I just made something
I'm using TortoiseSVN. I just made quite a few changes to my working copy
I just got a fix on another post I just made but this created
This script of mine has a function, which is not working the way, I
I made a script to copy,rename and change Bundle Id of a project from
I made a script to get JSON data from a file on our server
EDIT: I just made a jsfiddle to demonstrate the problem here: http://jsfiddle.net/GvjRd/3/ I have
I have just made a script in Python which will connect to my MySQL

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.