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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:26:28+00:00 2026-06-16T13:26:28+00:00

I have a mobile single-page web application that is built using jquery-mobile (jqm) and

  • 0

I have a mobile single-page web application that is built using jquery-mobile (jqm) and knockout. The application itself has multiple pages but they are all contained within a single HTML document.

Problem: after changing my “create view model for page” from sync to async behavior, I have the problem that jquery-mobile fires its events before the data is ready.

Background: up until recently I had been working with sample data, basically a huge JSON blob, and everything worked smoothly. With the new async composition of view models from various sources, data is not ready immediately and my “buildViewModel” method takes a continuation callback instead of just synchronously returning data.

I’m subscribing to the pagebeforecreate and pagebeforechange events, and fire off the code to populate the viewmodel here. The problem is that after returning from the event handler, jqm triggers the remaining chain of events before the data is available. This causes a page transition to an unprepared page, which is undesirable.

I have tried to call event.preventDefault in all of the before-events and manually calling $.mobile.changePage once the page is ready to be a) enhanced and b) the page transition to occur, but without any luck.

I’ve scanned the jquery-mobile source, but couldn’t spot anything that looked like it would allow me to delay the pagebeforeshow event, which is essentially what I need in order to be able to render the page properly.

How can I ensure that 1) data is available and 2) knockout has been applied to perform initial DOM manipulations, before jquery-mobile attempts to enhance the page and before it executes the in-transition to the page?

I also considered using synchronous ajax to fetch resources, but this will (I think) not work for resources loaded from the device (using PhoneGap/Cordova), and has other negative consequences that I’d like to avoid.

FWIW, I’d like to avoid having to manually handle all navigation events by wiring up click-handlers everywhere, but I’m open to all solutions if need be.

Apologies if this is a duplicate; I’ve searched and read a ton of questions, but not found an answer or question that was quite the same. It just sounds incredible that I would be the first to hit this problem, as I imagine it is a common scenario..

Update: clarified problem scenario description.

  • 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-16T13:26:29+00:00Added an answer on June 16, 2026 at 1:26 pm

    I had this exact same problem.

    The only solution I’ve been able to come up with is to write a custom transition handler that defers starting the transition until the Ajax request completes.

    Here’s a fiddle showing the technique. The fiddle doesn’t use Knockout, but does show how to defer the transition.

    Basically, since $.ajax() returns a promise, I can pipe that into the promise returned by the default transition handler and return it from my new handler.

    In my pagebeforeshow handler, I attach the Ajax promise to the page so that the transition handler has access to it. Not sure if this is the best way, but I liked it better than using a global variable.

    The only thing I didn’t like about this is that it delays the start of the transition until the Ajax response arrives so it could feel like the page has “hung” to the user making them click again. Manually showing the loading message makes it feel a bit more responsive.

    Hope this helps and please let me know if you find a better solution!

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

Sidebar

Related Questions

I have a single html page that I'm using jquery mobile on to create
I have a single page jQuery mobile application that consists of several list views
I have a web application that sends a single sms to multiple numbers via
I have a website built with jquery mobile(Single page). I have something like a
I'm using jquery mobile and backbone.js to create a single page mobile application. The
We are building a single page application using jQuery Mobile framework. the scenario we
I have a single page jquery mobile application in which there are few parent
I am trying to develop the single page in asp.net web mobile application as
I have developed an application using J9 that runs in windows mobile. but now
Say I have a mobile web app written using JQuery Mobile, this app retrieves

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.