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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:37:14+00:00 2026-05-16T02:37:14+00:00

I recently asked a question (and had it answered) here: jQuery Load JSON I

  • 0

I recently asked a question (and had it answered) here: jQuery Load JSON

I have a follow-up question, I was hoping to receive some advice on. Basically, I am loading data into the following div: "#my_div", which is actually a child element of another div, "#accordion", which is an accordion (jQuery UI).

My code looks like this:

$("#accordion").accordion({collapsible: true, clearStyle: true });

function load_list() {
 $.getJSON('json/load.php', function(data) {
        $("#my_div").empty();
        $.each(data, function(k, v){                                 
        $("#my_div").append('
                                     <li> \
                                      <div> \
                                       <input type="checkbox"> \
                                      </div> \
                                      <div>'+v.due_date+'</div> \
                                      <h3> \
                                       <span>'+v.title+'</span> \
                                       </h3> \
                                      </li> \
                                              ');
                                    });
});
}

And the HTML:

 <div id="accordion">
     <div id="my_div">JSON elements loaded here.</div>
 </div>

However, the problem is: upon the page loading, and then the JSON elements, the accordion does not automatically resize to fit JSON-loaded elements. Only if I collapse the accordion, and then reopen, you can properly see the elements. (This happens in both FF and IE).

I have tried placing $("#accordion").accordion({collapsible: true, clearStyle: true }); at the end of the load_list() function, but am still getting the same result. Any help on this would be great.

Thanks very much!

UPDATE:

Per the suggestions below, I have tried a few different methods, but am still running into the same issue.

Here is the most recent code I have tried:

 function load_tasks() {

            $.ajax({
                  url: 'json/load.php',
                  dataType: 'json', 
                  success: function(data) {
                      $.each(data, function(k, v){
                                $(("#my_div").append('
                                 <li> \
                                  <div> \
                                   <input type="checkbox"> \
                                  </div> \
                                  <div>'+v.due_date+'</div> \
                                  <h3> \
                                   <span>'+v.title+'</span> \
                                   </h3> \
                                  </li> \
                                          ');
                                });                                         
                     $("#accordion").accordion({collapsible: true, clearStyle: true, autoHeight: true });
                        }
 });
 }

I have also tried the other suggestions of autoHeight (which is true by default, no?), as well as the ‘resize’ method.

None of these appear to be working, unfortunately. If anyone else has any suggestions, they’d be greatly appreciated. Or perhaps, this is just something that cannot be accomplished in this particular situation.

  • 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-16T02:37:15+00:00Added an answer on May 16, 2026 at 2:37 am

    Okay, I believe I figured it out. Although, I don’t think this is the “proper” way to achieve.

    I failed to mention previously that this accordion is actually within a “tab” using $.tabs() with jQuery.

    I noticed that when I remove the “tab” function altogether, it works fine (almost all of the snippets above load the accordion perfectly when the tabs are removed).

    As a result, I believe this has something to do with the accordion being inside of the tabs, and the way the elements are constructed upon page load.

    As a hack/workaround, I added the following code, which works perfect for now:

    setTimeout('$("#accordion").accordion({collapsible: true, clearStyle: true, autoHeight: true })', 1000);`
    

    I’m still unsure if there’s a better way to achieve this, but, nonetheless, waiting 1 second to load the accordion works for now.

    Thanks for all the suggestions.

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

Sidebar

Related Questions

I've recently asked and had answered this question and it's stopped the issue of
I had recently asked a related question In C# how do I have a
I was recently asked this question in an interview. Lets suppose I have 2000
Recently I have asked a question about what I should use to create self-contained
I asked a question [ here ] recently and it's just not providing me
Recently I asked a question on SO that had mentioned the possible use of
Quite recently, I asked a question about debugging a seg fault: What are some
I recently asked/accepted an answer to a question I had earlier: How can I
Ok I had asked a question recently based on this. But I need to
I recently asked a question on using volatile and was directed to read some

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.