Trigger a SimpleModal Resize

I recently ran into an issue where I needed to force Eric Martin’s SimpleModal jQuery plugin to resize and reposition itself, but couldn’t find an easy way in the API to do so. I found several answers on Stack Overflow and other sites, but all of them were too old, didn’t work, or required you to reinvent wheels. So I started digging through the source code itself, and this is what I came up with.

The $div variable refers to whatever content div container you put into the modal to begin with. We need its dimensions, plus padding, so that the plugin has an accurate idea of how much space it actually needs to accommodate.

var $div = $("#contactDiv");
$.modal.update($div.outerHeight(), $div.outerWidth());

This was tested in all modern browsers and SimpleModal version 1.4.3 (not the most modern version, so your mileage may vary).

About Kelly Carter

I'm a freelance web developer, doing business under the name Rainworks Web Development. I'm a skeptical technophile, voracious reader, softcore gamer, and haphazard tinkerer. I have a long-term partner, a cat, and no time for glass ceilings.

Speak Your Mind


This site uses Akismet to reduce spam. Learn how your comment data is processed.