1

ラチェット フレームワークを使用して、任意のページをスライドイン/スライドアウトできます。次のページにスライドする前に、最初にデータを取得する必要がある状況に到達します。データは取得できるのですが、ページのスライド遷移が消えてしまいます。これを行う方法はありますか?

ここにこの例のアンカーがあります:

<a href="next-link.html" data-transition="slide-in" data-want="I want this data here">Next link</a>

使ってみた、

$('a').each(function() {

`var $this = $(this);`

`$this.attr('data-ignore', 'push');`

`$this.click(function(e) {`

    `e.stopPropagation();`

    `//... get the data here $this.attr('data-want')`

    `$this.attr('data-ignore', '');`

`});`

});

4

2 に答える 2

0

これは私が使用するものです。「on」の利点は、タグがページに追加されるたびに機能することです。必要に応じて if ステートメントを削除できます。私は PhoneGap を使用しているため、いくつかの問題を回避できます。

        $(document.body).on('click', 'a', function(e){
            $(this).attr('data-ignore', 'push');    //disables ratchet push.js for now!
            var url = $(this).attr('href');
            if (url && url.indexOf('http') == -1) {
                location.href = url;
            }
        });
于 2015-11-25T02:34:14.130 に答える
0

.data()代わりに使用してください:

$this.data('ignore', 'push');

そしてそれを空に設定する

$this.data('ignore', '');
于 2014-05-29T18:18:20.180 に答える