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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:52:33+00:00 2026-06-12T08:52:33+00:00

Now, my question is ‘simple’ (the question is, the solution maybe not). I have

  • 0

Now, my question is ‘simple’ (the question is, the solution maybe not). I have a function that retrieves data using $.json(). The data has to be loaded into a <ul> using a function which is called from the ‘pageinit’/’pageshow’.
Though it does not load anything at all. BUT! When I refresh the page, it loads the pageinit completely without problems.

This is my jQuery;

$('#showsPage').bind('pageshow', function(event) {
    getShows();
});

/******* FUNCTIONS *********/
function getShows()
{
    // Loading.
    $.mobile.loading('show');

    // Load the data.
    $.getJSON("some url", function(json) {

        $("#listShows li").remove();

        $.each(json.data, function(index, show) {

            $("#listShows").append("<li><a href='#'>Stuff</a></li>");
            $("#listShows").listview('refresh');

            // Hide the loading.
            $.mobile.loading('hide');

        });
    });
}

Am I doing something drastically wrong? I have a pageinit running on a different page without problems.

  • 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-12T08:52:34+00:00Added an answer on June 12, 2026 at 8:52 am

    Due to jQuery Mobile’s AJAX handling of page transitions, you should delegate your event binding when binding to page-events, like pageinit or pageshow.

    Here is an example:

    $(document).on('pageshow', '#showsPage', getShows);
    

    This will make sure that the binding does not occur until the #showsPage element is actually in the DOM.

    Notice how you don’t need an anonymous function if you aren’t passing-in any arguments. In the case of not passing any arguments you can just pass the name of the function to the .on() method as the callback.

    Note that this delegated event handler needs to be bound whenever a user refreshes a page or deep-links into your site, so I suggest placing it in an external script and including that script in the <head> of each document (just before the end </body> tag works too, just not inside a data-role="page" element) so that any page refresh won’t break functionality on your site. Another method is to place code that is for a specific page inside the data-role="page" element so when it’s brought into the DOM via AJAX, your code will be parsed by jQuery Mobile.

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

Sidebar

Related Questions

I am altering the question now! I have the search working using the following:
I have a main page that has a children item. Now my question is,
Example code var jqxhr=$.getJSON(http://search.twitter.com/search.json?callback=?,{q:query}, function(data) { ... question. }); Question Now i need to
Question now asked on SU . I have a Windows XP laptop, and I
hi we are using FormsAuthentication.SetAuthCookie(profile.Id, false); Now the question is when does this cookie
I'm using TweenMax to make all tweens, fade in a projet. Now my question
Now this question has been asked before but I am not able to get
I have compiled my Qt application and now have the following question - now
ok, i have another question now. I have a bunch of beans loaded succesfully
I have a page using StackLayoutPanel. In that 3 stacks requires separate CellTables. Currently

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.