TulsaNewbie
TulsaNewbie

Reputation: 401

Google apps script and jquery mobile loader giving two spinners

Let me preface this by saying I want a spinner...

I don't necessarily care whether it loads when the page first starts up, or later. The problem I'm experiencing also doesn't seem to care, as I've tried it both ways.

Right this moment, I don't declare it at the top of the page. Because I have a lot of visualization stuff going on, I start that up and immediately pass some info to the spinner (which also starts it up):

google.load('visualization', '1', {packages:['controls'], callback: initializeTables});

function initializeTables() {
  provideInfo("loading proficiencies (Step 1/12)");
  //etc... }

function provideInfo(text) {
  $.mobile.loading( "show", {
    text: text,
    textVisible: true
  });
}

So that starts... fine... ish...

The problem is that there's actually two spinners started when that starts - one in front, one behind. Because the one in front is slightly offset from the one behind, I can see both.

If I later call:

$.mobile.loading( "hide" );

It only hides the front one, not the back one.

I've found I can hide both by saying:

$(".ui-loader").hide();

Which is great. But, I'd like to not see two in the first place. I've tried to puzzle out the jquery mobile documentation page, to no avail (it also mentions a "global method docs" but I haven't been able to find that link):

//This does not work:
$( ".ui-loader" ).loader( "option", "text", "Loading Page..." );

//Nor does this:
$( "#notify_div" ).loader( "show" );
$( "#notify_div" ).loader( "option", "text", "Loading Page..." );

Anyone know how to get it all into one spinner, or why it's loading two?

Upvotes: 0

Views: 93

Answers (1)

deblocker
deblocker

Reputation: 7677

Sadly, the current JQM documentation is for the 1.5 version which hasn't be released yet. You need to look directly at the source code of the 1.4.5 version. There is a JQM default which is showing the spinner when a page is loading. You can override this behavior at JQM initialization.

  <script type="application/javascript" src="js/jquery-2.2.4.js"></script>
  <script>
    $(document).on("mobileinit", function () {
      $.mobile.changePage.defaults.showLoadMsg = false;
    });
  </script>
  <script type="application/javascript" src="js/jquery.mobile-1.4.5.js"></script>

If You look at line 5847 of the JQM uncompressed source code, You will find all the configurable settings for that. Moreover, just for the sake of completeness, there is another setting where You can tell JQM to not show the spinner for already cached pages. Just look at line 5122 of the JQM uncompressed source code:

    // This delay allows loads that pull from browser cache to
    // occur without showing the loading message.
    loadMsgDelay: 50

Hope this help.

Upvotes: 1

Related Questions