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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:01:32+00:00 2026-05-27T14:01:32+00:00

How do I told jquerymobile to postpone executing mobileinit until DOM is loaded? I’m

  • 0

How do I told jquerymobile to postpone executing mobileinit until DOM is loaded?

I’m trying to create pages on the fly using templates & JSON. My problem is that JSON takes too long to load and jquerymobile has finished mobileinit event!

Example code:

    $(document).bind("mobileinit", function(){
        console.log("mobileinit");

        // get JSON & set template... should wait until this is done!
        getData();

        //SWIPE SWIPE
        $('div[data-role="page"]').live("swipeleft", function(){
            var nextpage = $(this).next('div[data-role="page"]');
            // swipe using id of next page if exists
            if (nextpage.length > 0) {
                $.mobile.changePage(nextpage, 'slide');
            }
        });
        $('div[data-role="page"]').live("swiperight", function(){
            var prevpage = $(this).prev('div[data-role="page"]');
            // swipe using id of next page if exists
            if (prevpage.length > 0) {
                $.mobile.changePage(prevpage, 'slide', true);
            }
        });
        console.log("mobileinit done");
    });
  • 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-27T14:01:33+00:00Added an answer on May 27, 2026 at 2:01 pm

    You can use jQuery.Deferred() to accomplish this.

    // Let's assume that getData returns a deferred.
    function getData() {
        return $.get('your/request/url');
    });
    
    $(document).bind("mobileinit", function() {
        // Now you can use the deferred returned from the getData function.
        getData().done(function() {
            //SWIPE SWIPE
            $('div[data-role="page"]').live("swipeleft", function() {
                var nextpage = $(this).next('div[data-role="page"]');
                // swipe using id of next page if exists
                if (nextpage.length > 0) {
                    $.mobile.changePage(nextpage, 'slide');
                }
            });
            $('div[data-role="page"]').live("swiperight", function() {
                var prevpage = $(this).prev('div[data-role="page"]');
                // swipe using id of next page if exists
                if (prevpage.length > 0) {
                    $.mobile.changePage(prevpage, 'slide', true);
                }
            });
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A colleague told me that using the following method: string url = SomeURL; string
I have been told to use log4j for my logging project,but before using log4j,
I have just been told to get looking into using SQL server reporting. Does
I was told recently by a Flash developer that I respect that using include
I was told that there is an increase in performance when using Canvas versus
I was recently told that using mongodb _id fields in a URL is unsafe.
I have been told to start using Classes and Namespacing in my jQuery code
Someone told me: If you are using Eclipse and don't see any blue words
Someone told me about a C++ style difference in their team. I have my
Someone told me about swamp diagrams explaning that they were useful to predict code

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.