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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:34:30+00:00 2026-06-09T11:34:30+00:00

Ok so I have started using jQuery Mobiles pre-fetch abilities. I’m using the link

  • 0

Ok so I have started using jQuery Mobiles pre-fetch abilities. I’m using the link method specified on this page http://jquerymobile.com/test/docs/pages/page-cache.html. The only problem is my swipe code fails to see the pages that were brought in via the pre-fetch. Please see this js fiddle for a working example of the problem.

http://jsfiddle.net/UurQC/1/

Any one have any thoughts as to what to try to get .next to find the new pages. I have also tried targeting them via

div.ui-page

And it still comes up as an empty selector in firebug.

  • 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-09T11:34:32+00:00Added an answer on June 9, 2026 at 11:34 am

    The issue is that you are attempting to select the next DOM element, not the next pesueo-page element. Since you are adding the last page after the DOM loads, it’s actually being added after another element (so .next() is selecting this other element instead of the pseudo-page).

    I changed:

    $(this).next("div:jqmData(role='page')");
    $(this).prev("div:jqmData(role='page')");
    

    To:

    $(this).nextAll("div:jqmData(role='page')").first();
    $(this).prevAll("div:jqmData(role='page')").first();
    

    Which selects all the previous/next pseudo-pages and then selects just the first of those.

    Here is a demo: http://jsfiddle.net/UurQC/2/

    If you don’t delegate the event handlers for the swipe events then the swipe event handlers won’t run for the dynamically placed pseudo-page. Here’s how to fix that:

    $(document)
        .on("swipeleft", "div:jqmData(role='page')", function(){
            var $nextPage = $(this).nextAll("div:jqmData(role='page')").first();
            // swipe using id of next page if exists
            if ($nextPage.length > 0) {
                $.mobile.changePage($nextPage, { transition: 'slide' });
            }
        })
        .on("swiperight", "div:jqmData(role='page')", function(){
            var $prevPage = $(this).prevAll("div:jqmData(role='page')").first();
            // swipe using id of next page if exists
            if ($prevPage .length > 0) {
                $.mobile.changePage($prevPage, { transition: 'slide', reverse : true });
            }
        });
    

    And here is a demo: http://jsfiddle.net/UurQC/3/

    UPDATE

    Here is what the DOM looks like and why the above is necessary:

    <div data-role="page" id="text_0" data-url="text_0" tabindex="0" class="ui-page ui-body-c ui-page-active" style="min-height: 452px; "></div>
    <div data-role="page" id="text_1" data-url="text_1"></div>
    <div data-role="page" id="text_2" data-url="text_2"></div>
    <script type="text/javascript">...</script>
    <div data-role="page" id="text_3" data-url="text_3"></div>
    <div class="ui-loader ui-corner-all ui-body-a ui-loader-default"></div>
    

    Note that this is not the full HTML but only the direct children of the <body> element.

    Notice that the dynamically created pseudo-page is added to the DOM after JSFiddle added your JS code in a <script> tag. This will be an issue when not run on JSFiddle as well, as jQuery Mobile adds a loader element as it initializes.

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

Sidebar

Related Questions

Let me preface this question. I have just started using jquery, so please be
I have started using leaflet as an open source map, http://leaflet.cloudmade.com/ The following jQuery
I have started using jQuery and rails. I have made a simple form that
I have started using ajax/jQuery in our websites / application. There are many plugins
I have just started using jQuery and although following code gets the job done,
I have started using the DataTables plugin (v1.6.2) for jQuery (v1.4.2), and I would
Guys i am very new to jQuery. I have started using the auto complete
I have just started using jQuery in the past couple of weeks and am
We have started using Wijmo (based on the jQuery UI & jQuery UI Theme
I have just started using JQuery, and i know you can use .click with

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.