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 8493413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:00:00+00:00 2026-06-10T23:00:00+00:00

While trying to use this jquery lightbox plugin for Bootstrap (click for source code),

  • 0

While trying to use this jquery lightbox plugin for Bootstrap (click for source code), I stumbled upon a strange problem about how jQuery plugins work.

I have a containing div for the lightbox:

<div class="lightbox fade" id="demoLightbox" style="display: none;">
    <div class='lightbox-content'>
        <img src="image.png">
    </div>
</div>

If I:

  1. Open the lightbox with $("#demoLightbox").lightbox()
  2. Close it with $("#demoLightbox").lightbox('hide')
  3. Change the image through AJAX
  4. Ask to reopen a nre lightbox with $("#demoLightbox").lightbox()

then the second lightbox appears, but has the same dimensions than the first one; they have not been recomputed according to the new image!

The size calculations are done in the constructor of the Lightbox class, so I thought that $("#demoLightbox").lightbox() would give me a new instance and do the calculations again. But it seems that I got the same one! What happened ?

  • 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-06-10T23:00:03+00:00Added an answer on June 10, 2026 at 11:00 pm

    If the size calculations are only in the constructor, the simplest thing to do is create a new instance, as you attempted. However, you will first need to remove the old instance:

    $('#demoLightbox').removeData('lightbox');
    

    If you want a new instance in one fell swoop then

    $('#demoLightbox').removeData('lightbox').lightbox();
    

    Update: A Less Destructive Option

    This plugin seems to have some undocumented features, one of which might be useful for what you are trying to accomplish. Namely, there is a flag in the options called resizetofit. By default it is set to false. This flag is used to have the lightbox size itself to fit the window size. In the process of resizing it will recalculate the dimensions of the content.

    Adding the attribute data-resizetofit="true" to either the markup of the initiating link or to the <div class="lightbox" > should trigger a recalculation of the content on each call to the show() method.

    Note: The recalculation of the dimensions of the content will only occur if the <img> is replaced with a completely new <img>. Merely changing the src attribute will fail because the dimension calculations are cached onto the element after the first calculation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use this jQuery postMessage plugin to pass messages between a couple
I am trying to use sortable, a jQuery plugin and while it works great
I am getting some problems while trying to use this regex: (public +function|private +function|function)
I'm receiving this PHP error while trying to use the Normalizer class, specifically the
I'm getting an error while trying to use the action_mailer_tls plugin to communicate with
in this page: http://www.studiokhalid.com/test/jquery/2.html I am trying to use a simple Jquery Coda slider
I'm trying to use JQuery BGStretcher and a sticky footer setup and while they
I'm working with MVC recently and I've encountered a strange problem while trying to
i'm trying to use a scrollbar plugin written with jquery : tinyscrollbar. you can
I'm trying to use this script from Github at https://github.com/blueimp/jQuery-File-Upload The script has js

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.