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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:41:29+00:00 2026-05-31T08:41:29+00:00

I’m a newbie with jQuery Mobile and I’m working with a list that is

  • 0

I’m a newbie with jQuery Mobile and I’m working with a list that is dynamically generated with ajax. Now I had some help to get this to load certain amount of items then with a “Load More” button to populate more items into this list. I have a few issues I can’t seem to figure out.

  1. I can’t get the “Load More” to append to the bottom

2 The “Load More” button appends multiple times in my list when clicked. It keeps the last button clicked in place then adds a new one further down.

Here is my code:

This is what is generating content on page load

function runBrowse() {

        //Check if all fields have a value
        $.ajax({
            url: "http://www.example.com",
            data: {firstName: "", middleName: "", lastName: "", resultSize:10},
            success: browseSuccess,
        });
    }

    function runBrowseContinue(restart) {

        //Check if all fields have a value
        $.ajax({
            url: "http://www.example.com",
            data: {restartLine: restart, resultSize:10},
            success: browseSuccess,
        });
    }



    function browseSuccess(browseResults){
        $.mobile.changePage('#results');
        restartLine = browseResults.restartLine;
        jQuery.each(browseResults.people,handlePerson);
    }



    //Usage getMoreData(browseResults.restartLine);
    function getMoreData(restartLine){
        if(restartLine){
            runBrowseContinue(restartLine);
        }
    }

    function handlePerson(index, value) {
        var output = '';

        // Add these returns to listview
        output += '<li>' + '<h3>' + value.name + '</h3>' + '<p>' + value.height + '</p>' + '<p>' + value.weight + 'lbs.' + '</p>' + '</li>';
        $('#listview').append(output).listview('refresh');
    }

This is the Load More code

$loadMore = $('ul').children('.load-more');
    $loadMore.bind('click', function () {
        var out = [];
        out.push(getMoreData(restartLine));
        $('ul').append(out.join('')).append($loadMore).listview('refresh');
    });

This is my HTML

  <ul data-role="listview" class="listContent" id="listview">

    <li class="load-more"><a href="#">Load More</a></li>
  </ul>
</div>

Thanks for any help 🙂

Screen shot of this:

http://cl.ly/2l0w3I0G0f112f381g1f

http://cl.ly/0N002X2Z45320r2Y1K38

  • 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-31T08:41:30+00:00Added an answer on May 31, 2026 at 8:41 am

    From your screenshots it appears as though the handlePerson function is adding more “people” to the list without moving the “Load More” button to the bottom, which will account for having list-items below the “Load More” button.

    function handlePerson(index, value) {
        var output = '';
    
        // Add these returns to listview
        output += '<li>' + '<h3>' + value.name + '</h3>' + '<p>' + value.height + '</p>' + '<p>' + value.weight + 'lbs.' + '</p>' + '</li>';
        var $loadMore = $('#listview').children('.load-more');
        $('#listview').append(output).append($loadMore).listview('refresh');
    }
    

    When you append a DOM element that already exists, jQuery will move it to the new location and remove it from the old: http://api.jquery.com/append

    I would like to warn against this however. This makes two DOM manipulations for every index (“person”). It would be better to buffer all of the list-item output, and append it at once, which will take a slight re-flow of your code:

    function browseSuccess(browseResults){
        $.mobile.changePage('#results');
        restartLine = browseResults.restartLine;
        var out = [];
        jQuery.each(browseResults.people,function (i, v) {
            out.push(handlePerson(i, v));
        });
        var $loadMore = $('#listview').children('.load-more');
        $('#listview').append(out.join('')).append($loadMore).listview('refresh');
    }
    
    function handlePerson(index, value) {
        return '<li>' + '<h3>' + value.name + '</h3>' + '<p>' + value.height + '</p>' + '<p>' + value.weight + 'lbs.' + '</p>' + '</li>';
    }
    

    As you can see it would be easy to just remove the handlePerson() function all together and place it’s code inside the $.each() loop in the browseSuccess() function.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.