0

jquery.address() を使用して、ajax を介してページをロードします。

$.address.state('').init(関数() {

// Initializes the plugin
$('#menu a').address();
$('#nextprev a').address();

}).change(function(event) {

// Loads the page content and inserts it into the content area
$.ajax({
    url: $.address.state() + event.path,
    error: function(XMLHttpRequest, textStatus, errorThrown) {
      console.log(XMLHttpRequest.responseText);
    },
    success: function(data, textStatus, XMLHttpRequest) {
      $('title').html($('title', data).html());
      $.address.title(/>([^<]*)<\/title/.exec(data)[1]);
      $('#content').html($('#content', data).html());
      loadstuff();
      startAnimation();
    }
});

var startAnimation = function(data) {
... some animation going on here
});

現在、コードが ajax を呼び出して次のページをロードした後、次のページは startAnimation() を介して飛び込みます。それは今のところ本当にうまくいっています。

ただし、#nextprev 内に #next 要素と #prev 要素があります。それらのどれがクリックされたかを調べてから、別の関数 (つまり、startAnimation2()) をロードするアドレスが必要です。

4

1 に答える 1

0

マークアップ属性(または非表示の入力/ローカルPCメモリ)で現在のアニメーションインデックスを定義する必要があります。

<input type="hidden" value="3" name="current-animation" />

次に、値を取得します。

$('input[name="current-animation"]').val();

マークアップによる代替:

<div id="animation-data" data-current="3" data-animation="animation-1"></div>
于 2011-08-21T13:28:21.260 に答える