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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:13:19+00:00 2026-06-11T03:13:19+00:00

I am using jquery-ui tabs and dialog functionality. Each tab has a button on

  • 0

I am using jquery-ui tabs and dialog functionality.

Each tab has a button on the page which opens a dialog. This works for one of the tabs. However if I go the second tab, the button does not work there. When I come back to the first tab, the dialog does show up but the problem is I notice as I make switches back and forth to the first tab, it keeps on inserting new div’s while the old div’s have display:none set on them.

I am doing this using JSP. This is how the reusable jsp looks like:

<script>
$(function() {
    var formData = null;
    $.ajax({
        url : "addFormGenerator.html",
        success : function(data) {
            formData = data;
            $("#addFormDialog").html(data);
            $("#addFormDialog").dialog({
                autoOpen : false,
                height : 300,
                width : 350,
                modal : true,
                buttons : {
                    "Add" : function() {
                        $(this).dialog("close");
                    },
                    Cancel : function() {
                        $(this).dialog("close");
                    }
                },
                close : function() {
                }
            });
        }
    });
    $("#addButton").button().click(function() {
        $("#addFormDialog").html(formData);
        $("#addFormDialog").dialog("open");
    });
});
</script>

<button id="addButton">Click here to Add New</button>
<div id="addFormDialog" title="Add New"></div>

This jsp fragment is included in other jsp pages as well.
I was assuming as I switch between tabs the old button will be garbage collected.

Can you help me understand the problem and fix 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-11T03:13:20+00:00Added an answer on June 11, 2026 at 3:13 am

    You need not render the following part from your jsp’s response

    <div class="addFormDialog" title="Add New"></div>
    
    $("#addButton").button().click(function() {
            $("#addFormDialog").html(formData);
            $("#addFormDialog").dialog("open");
    });
    

    Just have the following, ideally with class names and not duplicate id’s

    <button class="addButton">Click here to Add New</button>
    

    UPDATE:

    I still don’t think you need unique id’s –

    <div id="tabs-container">
    
        <!-- tabs here -- >
    
        <-- let's say this is tab#1 -->
           <button class="addButton">Click here to Add New</button>
           <div class="addFormDialog" title="Add New"></div>
        <!-- tab1 -->
    </div>
    
    
    $('#tabs-container').on('click' , '.addButton', function(){
        var dialogContent = $(this).siblings('.addFormDialog');
        //now call .dialog({..});  or whatever you need
    });
    

    This way you’re binding just one click handler that listens to any click that bubbles up from a .addButton and then searches for its sibling .addFormDialog. (I hope I’m not sounding too confusing)

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

Sidebar

Related Questions

I'm using jQuery UI tabs for simple tab navigation on a page, and this
I have a page that is using jQuery tabs. Within one of my tabs
I have a jQuery dialog that holds multiple tabs, each tab contains a form,
i am using jquery tabs, and trying to get pagination in each one, everything
So I'm using jquery tabs for a page with a form, and we're using
I'm using jQuery tabs. In one of the tabs is a wysiwyg editor that
I am using jQuery UI Tabs . <div id=tabs> <ul id=tablist> <li><a href=#fragment-1><span>One</span></a></li> </ul>
I will be using some jQuery below this chunk of code (which I may
I'm using jQuery tabs, and I added some spans to the tab headers so
I am using jQuery Tabs for my project, with lazy loading tab content via

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.