1

jQuery mobilepagebeforeloadイベントを発生させようと必死になっています。これは何もしません:

 $(document).on("pagebeforeload", function( e, data ) {
        console.log("hello");
    });

JQMのドキュメントによると、構文は正しいです。それでも、何も起こりません。なぜそうなのか誰か教えてもらえますか?

4

2 に答える 2

4

あなたのコードは私のためにそのまま機能しました。

ここに画像の説明を入力してください

これは、別のページをロードしている場合にのみ機能することに注意してください。実際にページをロードしていないため、内部でリンクされたページでは機能しません。

于 2012-04-16T22:08:14.700 に答える
2

含まれていることを確認してください。含まれていないpreventDefault();場合は、ロードを続行します。

ドキュメント: http: //jquerymobile.com/demos/1.1.0/docs/api/events.html

$( document ).bind( "pagebeforeload", function( event, data ){

    // Let the framework know we're going to handle the load.

    event.preventDefault();

    // ... load the document then insert it into the DOM ...
    // at some point, either in this callback, or through
    // some other async means, call resolve, passing in
    // the following args, plus a jQuery collection object
    // containing the DOM element for the page.

    data.deferred.resolve( data.absUrl, data.options, page );

});
于 2012-04-16T21:10:39.760 に答える