Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 706861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:12:47+00:00 2026-05-14T04:12:47+00:00

Is there a way that I could trigger an onresize() event for my window

  • 0

Is there a way that I could trigger an onresize() event for my window in javascript/jQuery?

I tried:

$(window).resize();

but that didn’t seem to work exactly as expected. The simplemodal jQuery plugin gives you the option to autoPosition your modal window. Sometimes in IE, the modal shows up a little off center but as soon as I manually make a change to the window size it centers perfectly. So I want to just trigger the onresize event so this will automatically center with the autoPosition of simplemodal set to true.

Ok, I think part of my problem was that I was trying to make the height of the modal dynamic, if the content would change in the modal by showing or hiding elements, so would the size respectively.

Heres my modal call:

$(selector).modal({
    //autoPosition: true,
    //autoResize: true,
    onShow: function(dlg) {
        $(dlg.container).css('height', 'auto') // dynamic height based on content
    },
    onOpen: function(dialog) {
        dialog.overlay.fadeIn('slow', function() {
            dialog.data.hide();
            dialog.container.fadeIn('slow', function() {
                dialog.data.slideDown('slow');
            });
        });
    },
    onClose: function(dialog) {
        dialog.data.fadeOut('slow', function() {
            dialog.container.hide('slow', function() {
                dialog.overlay.slideUp('slow', function() {
                    $.modal.close();
                });
            });
        });
    }
});

If I comment out the onShow attribute, things work again. So I guess maybe that was part of the issue. Is there a way to resize the modal dynamically based on a content, that won’t creat this problem ?

Using simplemodal-1.3.4

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:12:48+00:00Added an answer on May 14, 2026 at 4:12 am

    Your approach should work, but may not trigger the simplemodal event you want, example:

    $(window).resize(function() {
      alert("resized");
    });
    $(window).resize(); //alerts "resized"
    

    A solution for your particular problem might be:

    $(window).trigger('resize.simplemodal');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there a way that I could automatically format the input box via Javascript
Is there any way that I could get the source of a website (as
Is there a way that we could override the default mac address / set
Is there a way/tool that could show me all the classes/interfaces that implement a
Is there a generic way to clone objects in VBA? So that i could
Is there a way to listen for a javascript function to exit? A trigger
Is there any way that I can programmatically create (and I guess access) hidden
Is there any way that I can change how a Literal of a code
Is there a way that you can have SERVEROUTPUT set to ON in sqlplus
Is there a way that my .NET CF app running on a Windows CE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.