I am trying to write a quick plugin that will load some AJAX content in a jQuery user interface dialog and resize and center the dialog accordingly. Here's the gist of what he does:
$(mySelector).html('Loading...').load(options.url, function() { element = $(mySelector); element.dialog('option', 'height', element.height() + 50); element.dialog('option', 'width', element.width()); element.dialog('option', 'position', 'center'); });
The height seems OK (adding some to fill out the dialog box additions), but the width ALWAYS 274 doesn't matter. I think the dialogue itself sets size limits. How can I configure it to be the natural width of the loaded content?
Edit / Addition: It returns the default size for the modal. Because even if it contains wider content (say, an image of 500 pixels), the parent container (mySelector) may not be so wide (at least in FF), so it was always by default (300 - padding = 274). Is there a way to automatically determine what width of returned content will be minimal without scrolling?)
source share