Can .dialog() and .position() be used together in peaceful harmony?
I'm using:
- jQuery 1.4.1 (due to the 1.4.2-vsdoc.js not being available as of yet)
- jQuery UI 1.8
- ASP.NET 3.5 (VB.NET)
I'm trying to position my dialog in the center of my container div which wraps around all of my master page content. I don't want to do a position [x,y] scenario where I have to formulaically figure out the appropriate x,y with regards to the top/left/height/width of the parent and the height/width of the dialog. That's exactly what .position() helps us with and I would really like to use it with dialog() to easily plop it right there in the dead center of that container div. Below, I created a VERY dumbed-down example of the HTML markup and then 2 cases of how I was hoping I could use position(). Is there anyone that can tell me if it's possible?
HTML markup:
- <div id="parent">
- <span>This is my parent container.</span>
- <div id="dialog">
- <span>This is my dialog.</span>
- </div>
- </div>
dialog() and position() try #1:
- $('#dialog').dialog({
-
- autoOpen : false,
- buttons : {
-
- 'Yes' : function() { $(this).dialog('close'); alert('Yes'); },
- 'No' : function() { $(this).dialog('close'); alert('No'); }
- },
- modal : true,
- position : {
- of : $('#parent'),
- my : 'center',
- at : 'center'
- },
- title : 'My Dialog',
- width : ' 200px'
- });
dialog() and position() try #2:
- $('#dialog')
- .dialog({
-
- autoOpen : false,
- buttons : {
-
- 'Yes' : function() { $(this).dialog('close'); alert('Yes'); },
- 'No' : function() { $(this).dialog('close'); alert('No'); }
- },
- modal : true,
- title : 'My Dialog',
- width : '200px'
- })
- .position({
- of : $('#parent'),
- my : 'center',
- at : 'center'
- });