opening jquery dialog

opening jquery dialog

I am able to display jQuery dialog on click.
I have added a div in c# code dynamically. I have opened a jquery dialog in the center of the div added using code.
When I click on the link the popup is opened. When I scroll the page the popup is also getting moved with the scrolling of the page.
What I want is that when the dialog is opened and I scroll the page the dialog should be in the centered of the parent div in which it is opened and it should not move from the parent.
I don't want to set popup as modal. So I have set its modal property to false.

sample code I am using.

function ShowDiv(element{   
    try {
        $(document.getElementById('myDiv'))
            .dialog({ height: 390, width: 380, title: title, show: "scale", hide: "scale",
                resizable: false, modal: false, autoOpen: true, overflow: scroll,
                overlay: { background: 'black', opacity: '0.9', zIndex: 10000 }
                            , position: {
                                my: 'center',
                                at: 'center',
                                of: mappingwebPartJquery(document.getElementById('parentdiv'))
                            }
            });
    }
    catch (ex) {
        var errorMessage = ex.Message;
    }
}

Please suggest how to do this.