4

can somebody help me and tell me why I can't center the JQuery UI Dialog

POS

<script src="js/jquery-1.7.1.js"></script>
<script src="js/jquery.ui.core.js"></script>
<script src="js/jquery.ui.widget.js"></script>
<script src="js/jquery.ui.button.js"></script>
<script src="js/jquery.ui.mouse.js"></script>
<script src="js/jquery.ui.resizable.js"></script>
<script src="js/jquery.ui.dialog.min.js"></script>
<style type="text/css" title="currentStyle">
</style>
<style> 
    </style>

<script>
$(function() {
    $('#addDialog').dialog({modal:true,buttons: {
            "Delete all items": function() {
                $( this ).dialog( "close" );
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        },position: 'center'});

    $("#resizable").resizable({
        animate: true,
        maxWidth: 400,
        minWidth: 300,
        containment: ".fullscreen"
    });

});
</script>

  </head>
 <div id='addDialog' style="display: none;">
iohio
 </div>
 <body id="dt_example" style='overflow:hidden;'>


 <div class="fullscreen" style='overflow:hidden;'>

 <div style='float: left; height:90%;' id="resizable" >


 </div>

 <div id="resizable2"  style='height:90%; overflow:hidden;'>

 <div id="container">

 <div id="demo">

 </div>

</div>

</div>

</div>
</body>
</html>
3
  • Your left side accordion menu doesn't push the page down when fully expanded. Also, it'd help if you posted the initialization source for us here, rather than expecting us to dig through your site's source. Commented Mar 26, 2012 at 16:44
  • Please include relevant source code in your question. Commented Mar 26, 2012 at 16:48
  • Working here jsfiddle.net/A9QTw/1 Commented Mar 26, 2012 at 17:02

3 Answers 3

1

EDIT:

Looks like you should also add a reference to UI Position per the dialog documentation here: http://jqueryui.com/demos/dialog/

Also, to prevent this in the future, build your download here: http://jqueryui.com/download so that all dependencies will be automatically downloaded for the features you want.

Move your addDialog div inside your <body> tag

This...

<div id='addDialog' style="display: none;">
    iohio
</div>
<body id="dt_example" style='overflow:hidden;'>

should be

<body id="dt_example" style='overflow:hidden;'>
  <div id='addDialog' style="display: none;">
     iohio
  </div>
Sign up to request clarification or add additional context in comments.

4 Comments

Try adding the UI Position library. I don't see it referenced in your code and according to this: jqueryui.com/demos/dialog it's required.
In your code, you are referencing jquery.ui.widget.js, jquery.ui.core.js, jquery.ui.button.js, etc. You also need jquery.ui.position.js. See the dialog documentation under "dependencies".
I don't understand what you mean by "I pasted the whole code". I'm telling you how to fix it. Add a reference to the position js file. You can download it from the jqueryui site.
thank you buddy I didn't know that there's something called position.js
1

Dialog UI required "core, "widget", "position", and "dialog". You are missing "position".

Comments

0

This is how I solved the issue, I added this open function of the dialog:

  open: function () {
                $('.ui-dialog').css("top","0px");                                
                    }

This now opens the dialog at the top of the screen, no matter where the page is scrolled to and in all browsers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.