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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:37:51+00:00 2026-05-29T12:37:51+00:00

I want to insert something inside the modal window using Ajax, so I tried

  • 0

I want to insert something inside the modal window using Ajax, so I tried to manually open the modal window. The code looks like this

    $(function(){
        $('#modal-from-dom').modal({
            backdrop: true,
            keyboard: true
        });
        $('#modalbutton').click(function(){

            $('#my-modal').bind('show', function () {
                // do sth with the modal
            });
            $('#modal-from-dom').modal('toggle');

            return false;
        });
    });

The HTML is copied straight from bootstrap js page

<div id="modal-from-dom" class="modal hide fade">
    <div class="modal-header">
      <a href="#" class="close">×</a>
      <h3>Modal Heading</h3>
    </div>
    <div class="modal-body">
      <p>One fine body…</p>
    </div>
    <div class="modal-footer">
      <a href="#" class="btn primary">Primary</a>
      <a href="#" class="btn secondary">Secondary</a>
    </div>
</div>
<button id="modalbutton" class="btn">Launch Modal</button>

So the problem is clicking the button the first time seems to work just fine, after the second click the modal window shows for 1 second or so and then disappears. If I change ‘toggle’ to ‘show’, after the second click the backdrop won’t fade out completely. How can I debug this?

  • 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-29T12:37:53+00:00Added an answer on May 29, 2026 at 12:37 pm

    The way you are currently performing actions is likely the cause of the flickering. Essentially, what you are telling the browser is: update the content after the div has been shown. You are also telling jQuery to bind the onShow event EVERY time the link is clicked. That bind declaration should be made outside of the onClick event.

    What you should try, is to change your modal content BEFORE displaying it, allowing the browser to adjust the DOM appropriately before displaying it, reducing (if not eliminating) the flicker.

    Try something more like this:

    $(function(){
        $('#modal-from-dom').modal({
            backdrop: true,
            keyboard: true
        });
        $('#modalbutton').click(function(){
    
            // do what you need to with the modal content here
    
            // then show it after the changes have been made
    
            $('#modal-from-dom').modal('toggle');
            return false;
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do something like this INSERT INTO t (t.a, t.b, t.c) VALUES
I want to do something like insert into my table (select * from anothertable
I have something like this in my code: String boundary = thisIsMyBoundaryString; StringBuilder body
I want to insert something into a STL list in C++, but I only
I want something that can check if a string is SELECT , INSERT ,
I want to insert multiple invisible watermarks into my JPEG pictures through C# code.
I know something like this has been asked before, but the answer was sort
With jquery it's very easy to insert some element inside another element using the
I want to have a macro dbtest that can be used like this: (dbtest
So I have a database that has a structure something like this: [user_table] user_id,

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.