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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:53:14+00:00 2026-06-06T03:53:14+00:00

On my web page I am loading an editing form asyncronously with jQuery.get and

  • 0

On my web page I am loading an editing form asyncronously with jQuery.get and showing it inside of jQuery dialog. For some reason, multiple instances of the div that I am aplying .dialog on are being appended to document.body. Here is my loading code:

function openEditProjectDialog(event) {
    var projectNameToEdit = $(event.currentTarget).closest('.project-item').find('.project-name').text();
    var url = $("#EditProjectActionUrl").val();
    var dataString = 'name=' + projectNameToEdit + '&__RequestVerificationToken=' + encodeURIComponent($("input[name=__RequestVerificationToken]").val());

    $.get(url, dataString)
            .done(function (content) {
                $('.modal-popup').remove();
                var popupDiv = $('<div class="modal-popup"><div id="edit-project-block">' + content + '</div></div>').hide();
                var whatWeDialogOn = popupDiv.appendTo(document.body);
                whatWeDialogOn.dialog({
                    title: 'Editing project <b>' + projectNameToEdit + '</b>',
                    modal: true,
                    resizable: false,
                    draggable: true,
                    width: 725,
                    close: function(event, ui) {
                        $(this).dialog('destroy').remove();
                        $('.modal-popup').remove();
                    }
                });
                $("#edit-project-block #bottomAreaHtml").attr("id", "bottomAreaHtmlToEdit");
                CKEDITOR.replace('bottomAreaHtmlToEdit');
                $('.chzn-select').chosen();
                $("#edit-project-block #submit-project").on("click", submitUpdatedProject);

            });
}

$('#projects').on("click", '.edit-project', openEditProjectDialog);

At this point:

.done(function (content) {
    $('.modal-popup').remove();

there are two <div class="modal-popup" style="display:none"> already appended to a document. After .remove call there is one left. (I know there should be none =) After the .dialog is called, there are 6 or 7 modal-popup divs and the only one inside the jQuery UI div that is actually displayed.

If what I am describing sounds rediculouse – let me know. What may be the source of the problem?

P.S. var popupDiv = $('<div class="modal-popup">... is the only spot where div with such name gets added to the DOM.

  • 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-06T03:53:16+00:00Added an answer on June 6, 2026 at 3:53 am

    Try structuring the function to account for variable declaration hoisting and do your removals before additions (like so):

    function openEditProjectDialog(event) {
        var projectNameToEdit = $(event.currentTarget).closest('.project-item').find('.project-name').text();
        var url = $("#EditProjectActionUrl").val();
        var dataString = 'name=' + projectNameToEdit + '&__RequestVerificationToken=' + encodeURIComponent($("input[name=__RequestVerificationToken]").val());
        $.get(url, dataString).done(function (content) {
            var div = $('<div />'),
                editDiv = null,
                popupDiv = null,
                whatWeDialogOn = null;
            //Create the Editing div
            editDiv = div.clone().attr('id', 'edit-project-block').html(content);
            editDiv.find('#bottomAreaHtml').attr("id", "bottomAreaHtmlToEdit");
            editDiv.find('#submit-project').on("click", submitUpdatedProject);
            //Create the containing div
            popupDiv = div.clone().addClass('modal-popup').append(editDiv).hide();
            //Create the dialog
            whatWeDialogOn = popupDiv.dialog({
                "title": "Editing project <b>" + projectNameToEdit + "</b>",
                "modal": true,
                "resizable": false,
                "draggable": true,
                "width": 725,
                "close": function (event, ui) {
                    //$(this).dialog('destroy').remove();
                    $('.modal-popup').dialog('destroy').remove();
                }
            });
            //No need since none is there if everything closes right from before
            //$('.modal-popup').dialog('destroy').remove();
            //.dialog call does appending from within constructor. No need to append anything
            //$('body').append(whatWeDialogOn); 
    
            CKEDITOR.replace('bottomAreaHtmlToEdit');
            $('.chzn-select').chosen();
        });
    }
    $('#projects').on("click", '.edit-project', openEditProjectDialog);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page that contains two articles. Upon loading this page, jQuery
I've a JEditorPane inside a JDialog. I'm loading a web page when this JDialog
The context: My question relates to improving web-page loading performance, and in particular the
As per my knowledge when ever a web-page is loading, always header is loading
I am loading a web page in my iPhone app. However the page is
I am loading a specific web page in a WebBrowser control. Is there a
I am getting the following error in Firebug when loading a web page: redirect.processBrowser
A web page of a web application was showing a strange error. I regressively
I need some advice. I have a web page and want to extend it's
I'm loading web-page using urllib. Ther eis russian symbols, but page encoding is 'utf-8'

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.