1

jQuery 関数 (単独で動作):

$("#firstpage").live('pageinit', function (evt) {
    $("#firstpage").bind("swipeleft", function (e) {
        alert ("you swiped left!");
    });
});

jQuery モバイル リンク (単独でも動作します):

<a href="#secondpage" data-transition="slide">GO TO PAGE 2</a>

では、どうすれば2つを組み合わせることができますか?ありがとう!

4

2 に答える 2

2

を使用できます$.mobile.changePage()。これは、ページ間を移行するために内部的に使用されるものです。次に例を示します。

$(document).delegate("#firstpage", 'pageinit', function (evt) {
    $(this).bind("swipeleft", function (e) {
        $.mobile.changePage("#secondpage", {
            transition : 'slide'
        });
    });
}).delegate("#secondpage", 'pageinit', function (evt) {
    $(this).bind("swiperight", function (e) {
        $.mobile.changePage("#firstpage", {
            transition : 'slide',
            reverse    : true
        });
    });
});​

これがデモです:http://jsfiddle.net/QjUMh/

のドキュメントをチェックして、$.mobile.changePageそこにあるすべてのオプションを確認してください:http: //jquerymobile.com/demos/1.1.1/docs/api/methods.html

于 2012-08-03T05:59:48.763 に答える
1

$.mobile.changePage()メソッドを使用して行うことができます。

Jquery モバイル ドキュメント
http://jquerymobile.com/demos/1.1.1/docs/api/methods.htmlを確認してください。

$("#firstpage").live('pageinit', function (evt) {
    $("#firstpage").bind("swipeleft", function (e) {
       $.mobile.changePage("#secondpage", { transition : 'slide'});
    });
});
于 2012-08-03T07:04:28.013 に答える