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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:41:18+00:00 2026-06-08T06:41:18+00:00

I am working on a single page JQuery Mobile site. JQuery initialization is initially

  • 0

I am working on a single page JQuery Mobile site. JQuery initialization is initially set to false while JSON data is loaded and the DOM is manipulated client side. After the content is loaded and DOM manipulated, JQuery Mobile is initialized.

Once initialized, I am planning to use Ben Alman’s replaceText plugin to drop JSON into some placeholders that are within the outputted HTML, so a placeholder like “XXFIRST_NAMEXX” becomes “John Smith”.

I haven’t gotten to the replacement part b/c I am unable to access the JSON data from within JQuery Mobile’s pageshow() event, even though that the last event to fire in the sequence of events loading the page.

Below is a simplified and commented version of my code.
I am using JQuery 1.7.1 and JQuery Mobile 1.1.0
What am I missing here?
Thanks!

// jQuery Mobile initialization
$(document).bind("mobileinit", function () {
    //prevent JQM from initializing until after content has been loaded in .getJSON callback;
    $.mobile.autoInitializePage = false;
});

$( document ).bind( "pageshow", function( event, data ){
    console.log('pageshow fires'); //fires 4th

    //DROP-INS
    //need to replace text within manipulated and initialized html
    var resplaceScope, strDisplayName, strSchoolName, strOfferTitle; 
    replaceScope = $('body *');
    //collect variables from json data
    strOfferTitle = data.content.offer_vars.offer_title; //ERROR Uncaught TypeError: Cannot read property 'offer_vars' of undefined 
    replaceScope.replaceText( /XXOFFER_TITLEXX/gi, strOfferTitle );
});

$(document).ready(function(){

    console.log('document.ready fires'); //fires 1st

    $.getJSON('io_content.json', function(data) {
        console.log('getJSON fires'); //fires 2st
        getContent(data);
        // ... once code is manipulated by getContent, Jquery is ready to initialize
        $.mobile.initializePage();
    });

    function getContent(data){
        console.log('getContent fires'); //fires 3rd
        // ... code to manipulate content client side before jquery mobile initializes
    }

});
  • 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-08T06:41:19+00:00Added an answer on June 8, 2026 at 6:41 am

    I’m not entirely sure what’s going on, but is it possible that you’re expecting the “data” parameter passed into the “pageshow” callback to be the same as the “data” variable in the “getJSON” callback? They are different objects that just happened to both be named “data”. The one from “pageShow” just has a “prevPage” property that contains a reference to the DOM element that represents the page that was just navigated away from. The one in the getJSON callback has the actual data you got from the data source; once the callback finishes executing, it’s gone.

    If it’s not possible to do all of this initialization in the JSON callback, then you might try using jQuery’s data() function to store the bits of the JSON that you need on some DOM element in the page. http://api.jquery.com/jQuery.data/

    Does that help?

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

Sidebar

Related Questions

I have a single page jQuery Mobile app with four data-role='pages' in place; so,
I'm working on a single-page site with sliding content. I'm using jquery.form.js and am
I'm working on my first very complex JQuery based application. A single web page
I have a single page jquery mobile application in which there are few parent
I am working on a single page horizontal scrolling site that is 10,000 px
Jquery ticker working on my site home page perfectly , but not working on
I've got, what I would consider, a simple test web site. A single page
I am using multiple jquery cycle sliders on a single page that i am
I am working with jQuery mobile and using the HTML5 audio tag. I have
I'm using slidesjs to create 5 different slideshows/galleries on a single-page site. They all

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.