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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:06:07+00:00 2026-05-27T00:06:07+00:00

I currently am using a dynamically generated list view in jQuery mobile to display

  • 0

I currently am using a dynamically generated list view in jQuery mobile to display a bunch of data from a database. Although most of this content is in the database and generated by django before the page is loaded, there is also some content I’d like to insert into the list view elements that is stored using HTML5 localStorage.

As a result, this data can only be accessed via javascript, not the django backend. I envision binding some javascript to the pagebeforecreate event. After this, I need to somehow loop through all of the li elements within the ul (I have its id), except the first (since thats the divider).

After that it gets a bit tricky. Assume that I have an array already loaded up in javascript that has fetched the info from localStorage. Call it classNames. I’ve assigned a custom property period index, to each li identifying which index of the classNames array the given li should receive as text.

UPDATE

For example this the contents of a given list with look like before being enhanced by query.

    <li data-role="list-divider">Regular Schedule/li>
    <li periodindex="5" type="schedule">
        <h1 class="ui-li-heading">6</h1>
        <p class="ui-li-maintext"><i>class name goes here</i></p>
        <p class="ui-li-aside"><b>7:30</b> - <b>8:30</b></p>
        <p class="ui-li-count">60</p>
    </li>
    <li periodindex="3" type="schedule">
        <h1 class="ui-li-heading">6</h1>
        <p class="ui-li-maintext"><i>class name goes here</i></p>
        <p class="ui-li-aside"><b>8:45</b> - <b>9:50</b></p>
        <p class="ui-li-count">65</p>
    </li>
   <li periodindex="7" type="schedule">
        <h1 class="ui-li-heading">6</h1>
        <p class="ui-li-maintext"><i>class name goes here</i></p>
        <p class="ui-li-aside"><b>10:00</b> - <b>12:00</b></p>
        <p class="ui-li-count">120</p>
    </li>
   <li periodindex="0" type="schedule">
        <h1 class="ui-li-heading">6</h1>
        <p class="ui-li-maintext"><i>class name goes here</i></p>
        <p class="ui-li-aside"><b>1:00</b> - <b>4:00</b></p>
        <p class="ui-li-count">180</p>
    </li>

I need a way to loop through all the given li elements and replace the contents of “class name goes here” with the contents of the classNames array object at index specified by the periodindex property of the li element. Note also that the first li element in the list should be ignored as it is the title of the list.

  • 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-27T00:06:08+00:00Added an answer on May 27, 2026 at 12:06 am

    Assuming the classNames array is in the same order as the LI elements appear in your page, try this:

    Updated as per OPs responses

    for (var i = 0; i < classNames.length; i++) {
        $("#schedule li[periodindex='" + i + "']").find(".ui-li-maintext").html("<i>" + classNames[i] + "</i>");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an overlay that is dynamically generated from user data, so I need
I'm building a quiz web application that is dynamically generated from a database on
Currently I am using a for loop to dynamically load XML images and place
I'm using Microsoft Ajax to dynamically populate a list of contacts, given a json
I have a table of data which is generated dynamically with Javascript. Every few
I have a page that contains dynamically generated Dropdown List controls and I want
Currently struggling with PHP and creating KML from it. I'm using the last.fm API
I'm currently developing a web application using Struts2 framework. This application requires to dynamically
TL;DR I'm trying to dynamically generate an asset URL using HTML5 data elements, on
I'm currently building tests using Capybara/Rails, and want to know the most reliable/standard way

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.