I want to position my jQuery dialog x-pixels away from the right border of the browser. Is this anyhow possible?
http://jqueryui.com/demos/dialog/
The position option doesn't seem to have that kind of setup, but is there any other way to do it?
Syntax: $( ". selector" ). dialog({ position: { my: "left top", at: "left bottom", of: button } });
The . position() method allows us to retrieve the current position of an element (specifically its margin box) relative to the offset parent (specifically its padding box, which excludes margins and borders). Contrast this with . offset() , which retrieves the current position relative to the document.
dialog( { ... } ); Then check for the class when needed: if ($("selector"). hasClass("initialized")) { ... }
Difference between offset() and position() Method:The jQuery UI offset() is relative to the document. The jQuery UI position() is relative to the parent element. When you want to position a new element on top of another one which is already existing, its better to use the jQuery offset() method.
This keeps dialog div in fixed position
this works for me in IE FF chrome and safari
jQuery("#dialogDiv").dialog({
autoOpen: false,
draggable: true,
resizable: false,
height: 'auto',
width: 500,
modal: false,
open: function(event, ui) {
$(event.target).parent().css('position', 'fixed');
$(event.target).parent().css('top', '5px');
$(event.target).parent().css('left', '10px');
}
});
when you want dialog box open just call
$('#dialogDiv').dialog('open');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With