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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:32:34+00:00 2026-06-11T06:32:34+00:00

I have a big container with scrollbars. A modal dialog with jquery UI shall

  • 0

I have a big container with scrollbars.

A modal dialog with jquery UI shall open in the middle of this container.

The dialog opens, but after closing and opening again and again it moves up or down (and so it always has a wrong position).

I’ve added from this thread Can JQuery UI Dialog remember its position between opening and closing the following part:

beforeclose: function(){
   $(this).dialog('option', 'position', [$(this).offset().left, $(this).offset().top]);
}

If I remove this part, then the dialog opens after dragging/moving it around alway on top of the page.

Also, if the dialog is opened at the bottom, the movings are even crazier.

My code:

$("#btnTest").click(function(){
  if ($("#exec").length == 0) {

            $('body').append('<div id="exec" style="width:320px;background-color: #000;display:none;">xxx</div>');

          $("#exec").dialog({
            width: 320,
            modal: true,
            position: "center",
            show: { effect: "slide", direction: "up", duration: 400 },
            hide: { effect: "slide", direction: "up", duration: 400 }
         });
       } else {
            $("#exec").dialog("open");
        }
 });

$("#btnClose").click(function(){
    $("#exec").dialog('close');
});

Check it @ jsfiddle:
http://jsfiddle.net/EDkk6/4/

  • 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-11T06:32:35+00:00Added an answer on June 11, 2026 at 6:32 am

    There appears to be a 20px difference in the top position of the modal when it is reopened. I believe this is because the UI dialog is created within a parent div which you are not taking account for in your offset. Therefore, you need to get the offset based on the parent like so:

    beforeclose: function () {
        var $parent = $(this).parent();
    
        $(this).dialog('option', 'position', [$parent.offset().left,$parent.offset().top]);
    }
    

    Live DEMO

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

Sidebar

Related Questions

Hey, I have a big problem with my container-sketch. How can I realize this
I have a big <div /> container that has an image as a background.
I have an element which may contain very big amounts of data, but I
I have a var that contains a big list of words (millions) in this
I have a simple setup with one big image container and 3 smaller thumbnail
I have something like this: <div id=container> <img src= id=bigImg> </div> On the page
I have the following code: <div id=container> <div id=top>TOP TEXT </div> <div id=middle>MIDDLE TEXT
Lets say we have this markup: <div id=container> <ul></ul> <ul></ul> </div> Where the format
I have a web page with one big container for the entire page. Inside
i have this code in an itemtemplate in a gridview: <%# DataBinder.Eval (Container.DataItem, DiscountAmount)%>

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.