With many sites leveraging jQuery UI, there are some major shortcomings that have to be overcome because jQuery UI does not support responsive design and there's a longstanding bug when maxWidth
is used in conjunction with width:'auto'
.
So the question remains, how to make jQuery UI Dialog responsive?
I am not sure that my simple solution solves the problem of this question, but it works for what I am trying to do:
That is, the dialog opens with a 400px width, unless the width of the window requires a smaller width.
Not responsive in the sense that if the width is narrowed the dialog shrinks, but responsive in the sense that on a specific device, the dialog will not be too wide.
I just found a solution for this issue.
I pasted my css style, hope this can help someone
Below is how I achieved a responsive jQuery UI Dialog.
To do this, I added a new option to the config -
fluid: true
, which says to make the dialog responsive.I then catch the resize and dialog open events, to change the max-width of the dialog on the fly, and reposition the dialog.
You can see it in action here: http://codepen.io/jasonday/pen/amlqz
Please review and post any edits or improvements.
EDIT
Updated approach: https://github.com/jasonday/jQuery-UI-Dialog-extended
The repository above also includes options for:
If your site is restricted to a max size, then below approach will work. Attach a css style to your dialog.
The accepted solution is rather buggy and overengineered imo. I came up with dialogResize which is cleaner and more straightforward for my purposes.
Implement like so:
Demo
This Worked for me