Uncaught TypeError when trying to trigger 'load' using jQuery Mobile

I spent 5 hours trying to show a loading message using jQuery Mobile. Instead, I get:

Uncaught TypeError: Object # <Object> does not have a 'loading' method

Here is my code:

<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script> <script type="text/javascript"> $.mobile.loading("show"); </script> 

Here is the current code:

  <head> <title>My Page</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" /> <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script> <script type="text/javascript"> $.mobile.showPageLoadingMsg(); </script> </head> 
+4
source share
3 answers

The exception you encounter is due to an invalid method reference, as indicated in the error:

Uncaught TypeError: Object # does not have a 'loading' method

The loading() method was added in 1.2, but you are using 1.1.1, so it claims to have no loading method.

Show or hide the page load message, which is configured through $ .mobile.loader, as described in widget documents or can be controlled using the params object.

Using:

 //cue the page loader $.mobile.loading( 'show' ); //use theme swatch "b", a custom message, and no spinner $.mobile.loading( 'show', { theme: "b", text: "foo", textonly: true }); 

The method you should use for your version is showPageLoadingMsg() .

Using:

 //cue the page loader $.mobile.loadingMessage = 'Loading...Please wait'; $.mobile.showPageLoadingMsg(); //use theme swatch "b", a custom message, and no spinner $.mobile.showPageLoadingMsg("b", "This is only a test", true); 
+2
source

You are using jquery.mobile-1.1.1.min.js. jQuery mobile 1.1.1 is not supported

 $.mobile.loading("show"); 

and this method is in jQuery mobile 1.2.0.

Supported by

 $.mobile.showPageLoadingMsg(); 

And you can configure loadMessage in the mobileinit method.

Example:

  $.mobile.loadingMessage = "Loading Message"; $.mobile.loadingMessageTextVisible = true; $.mobile.loadingMessageTheme="a"; 

I had the same problem and finally I found it.

0
source

Finally I found a solution

it cannot be called directly from a simple javascript function, I need to use it with the page

 $("#Step1").live("pageshow", function () { $.mobile.showPageLoadingMsg(); }); 
-1
source

All Articles