JQuery dialog position when scrolling down

I use this javascript / jQuery to open a dialog, however, when I scroll down the page and open another window after closing the first window, the window opens in my selection position, plus the position I scroll down. When I try to move it, it will continue to jump down , causing a very annoying result.

function showDialog(url) {

    dialogFrame = $('<iframe style="width:100% !important;" frameborder="0" id="Dialog" src="' + url + '" />').dialog({
        autoOpen: true,
        height: 500,
        width: 1000,
        title: 'myWindow',
        resizable: false,
        modal: true,
        position: {
            my: "center",
            at: "center",
            of: window
        }
    });
}

How can I prevent this behavior? Probably it is position : { }, but what should it be?

+3
source share
1 answer

I had the same problems with the jQuery UI dialog when I bodyhad the CSS property position:relative;. You can check if this is true.

position:relative;, top :

$(".dialogFrame").dialog({
    // ...
    open: function(event, ui) {
        $(event.target).parent().css('position', 'fixed');
        $(event.target).parent().css('top', '20px');
    }
    // ...
});

script , .

+1

All Articles