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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:26:10+00:00 2026-06-09T19:26:10+00:00

I am trying to create a page that displays job information for computing jobs

  • 0

I am trying to create a page that displays job information for computing jobs submitted to UK computing grid. The page is intended to display the job information from couchDB in a nice accessible format. I want to use the jQuery accordion to display the information, so that I can have only the most relevant job information visible initially and then the user can browse the other sections for more detail, if required.

To do this I have two files:

  1. I have an HTML file (job.html):

    <html>
      <!-- source jquery, jquery.couch, bootstrap scripts //-->
      <script type="text/javascript" src="job.js"></script>
      <!-- script to define accordion //-->  
      <body>
        <div id="content">
          <h1 id="jobhead">Job Description : </h1>
          <hr/>
          <div id="accordion">
          </div>
        </div>
      </body>
    </html>
    
  2. and I have a javascript file (job.js) that queries the database, opens the correct job file and appends the HTML code to the accordion: (this previous stackoverflow question was very useful in doing this bit!)

    //define function 'get_parameter_by_name'
    
    //code to define database name $db
    
    var record_id = get_parameter_by_name('id');
    $(document).ready(function() {
    
        //Destroy accordion first:
        $('#accordion').accordion('destroy');
        //clear records
        $('#accordion').empty();
    
        //use .openDoc method to get job information, then append html
        $db.openDoc(record_id, {
        success: function(data) {
            //check correct data is accessed
            console.log(data);
    
            //html content of accordion appended, e.g
            html = '<h3><a href="#">Key Information:</a></h3>'; //Header 1
            html += '<div>'; //Start of content 1
            html += '<table id="keyData">';
            html += '<tr><td>Module</td><td>' + data.module + '</td></tr>';
            ...
    
            //append html
            $('#accordion').append(html);
    
            },
                error: function(e) {
                alert('Error loading from database: ' + e);
            }
        });
        //Remake accordion
        $('#accordion').accordion({ header: "h3", collapsible: true });
    });
    

My problem is that the html is being appended fine but it is not being formatted as an accordion – i.e. all the appended HTML is displayed at once and headings cannot be expanded/collapsed.

After playing around with the order a bit, I have worked out that it works fine if the code where I append the HTML is placed outside of the db.openDoc() method. This is fine for just text, but I need to display a lot of variables (not just those shown) that are defined in this method.

So my question is whether it is possible to store the variables that I need so they can be accessed outside the openDoc() method. Or alternatively if there is a way of appending the HTML within the method so that it works with accordion.

Any answers you can suggest would be greatly appreciated. Equally, I’ve only been learning javascript/HTML for a couple of weeks, so if there is a much easier approach that you can suggest, I’d be happy to here that too.

Thank you in advance!

  • 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-09T19:26:12+00:00Added an answer on June 9, 2026 at 7:26 pm

    You need to destroy accordion each time you get results from db.

    //Remake accordion
    $('#accordion').accordion('destroy').accordion({ header: "h3", collapsible: true });
    

    Check this jsfiddle

    Also, you don’t need to destroy accordion on page load, so remove following line:

    //Destroy accordion first:
    $('#accordion').accordion('destroy');
    

    EDIT: as @Shmiddty mentioned, you need to put line with remaking accordion into success callback.

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

Sidebar

Related Questions

I'm trying to create a page that contains a grid and searching. The issue
I'm trying to create the effect of a button that 'lifts' from the page
I am trying to create a page that displays a preview of all the
I'm trying to create a page that displays a list of employees. All the
I am trying to create a page, named Archive.aspx , that displays all my
I'm trying to create a page that displays statistics for every player. A sum
I am trying to create a page in my WordPress Admin Area that displays
Im trying to create a page for a university project that dynamically displays a
I'm trying to create a box on the side of a page that displays
I'm trying to create an app that displays an info page once a video

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.