4

jQuery Mobile を使用して読み込み中のメッセージを表示するだけで 5 時間かかりました。代わりに、私は得ています:

キャッチされていない TypeError: オブジェクト #<Object> にはメソッド 'loading' がありません

これが私のコードです:

<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>

現在のコードは次のとおりです。

    <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

3 に答える 3

2

発生している例外は、エラーに記載されているように、不正確なメソッド参照が原因です。

キャッチされていない TypeError: オブジェクト # にはメソッド 'loading' がありません

メソッドは 1.2 で追加されましたloading()が、1.1.1 を使用しているため、メソッドがないと記載されていますloading

ページの読み込みメッセージを表示または非表示にします。これは、ウィジェットのドキュメントで説明されているように $.mobile.loader プロトタイプ オプションを介して構成するか、params オブジェクトを介して制御できます。

使用法:

//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 });

お使いのバージョンで使用する必要があるメソッドはshowPageLoadingMsg().

使用法:

//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);
于 2012-07-18T02:12:12.463 に答える
0

jquery.mobile-1.1.1.min.js を使用します。jQuery モバイル 1.1.1 はサポートされていません

$.mobile.loading("show");

このメソッドは jQuery モバイル 1.2.0 にあります。

サポートされています

$.mobile.showPageLoadingMsg();

また、 mobileinitメソッドで loadMessageを設定できます。

元:

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

私は同じ問題を抱えていて、ついに見つけました。

于 2012-07-24T08:49:01.473 に答える
-1

最後に私は解決策を見つけました

単純なJavaScript関数から直接呼び出すことはできません。ページで使用する必要があります。

$("#Step1").live("pageshow", function () {
    $.mobile.showPageLoadingMsg();  
});
于 2012-07-18T02:26:23.097 に答える