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

  • Home
  • SEARCH
  • 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 7532145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:22:01+00:00 2026-05-30T05:22:01+00:00

I’m building a list of items in jQuery mobile from an array, and paginating

  • 0

I’m building a list of items in jQuery mobile from an array, and paginating them. The page’s header and footer are included by PHP via a wordpress function. Basically what I’m doing is calculating the number of pages I need to accommodate the elements in the array, then cloning the page element that number of times, and looping over them to add the elements to each. At the end of each page I’m putting previous and next buttons.

The problem is that the buttons do not change pages at all.

The page element looks like this:

<div data-role="page" id="press-media-page">

    <?php get_template_part("loop", "header"); ?>

    <div data-role="content">
        <h1>Press &amp; Media</h1>
    </div>

    <?php get_template_part("loop", "footer"); ?>

</div>

To create each page:

newPage = $("#press-media-page").clone().attr({
    "id": "press-media-page-" + pageNumber,
    "data-url": "press-media-page-" + pageNumber
}).page();

And then after adding the elements and buttons, to append it to the document:

$.mobile.pageContainer.append(newPage);

After I’ve created the pages, I loop over them and trigger the create event:

$("#press-media-page").trigger("create");
for (var i = 1; i < pages; i++)
    $("#press-media-page-" + i).trigger("create");

The page appears in the right place in the document, and the buttons are linked to the right page ID, but alas they don’t navigate.

What do I have to do to get this to work?

Edit

This is how I create the buttons:

if (pageNumber > 0)
    navButtonGrid.left.append("<a>").attr({
        "href": "#press-media-page" + ((pageNumber > 1) ? "-" + (pageNumber - 1) : ""),
        "data-role": "button",
        "data-icon": "arrow-l",
        "data-iconpos": "left"
    }).text("View Newer");
if (pageNumber < totalPages - 1)
    navButtonGrid.right.append("<a>").attr({
        "href": "#press-media-page-" + (pageNumber + 1),
        "data-role": "button",
        "data-icon": "arrow-r",
        "data-iconpos": "right"
    }).text("View Older");

I haven’t taken over any events from the buttons, just using jQuery mobile’s default link hijacking

  • 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-30T05:22:03+00:00Added an answer on May 30, 2026 at 5:22 am

    Okay, so it turned out to be a silly mistake:

    navButtonGrid.left.append("<a>").attr({ //...
    

    I append an <a> tag, but then I’m still working on the navButtonGrid.left element, which is a ui-block div. Changing it to

    navButtonGrid.left.append($("<a>").attr({ /* ... */ }));
    

    has solved the problem.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
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 want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.