0

jQuery 用のNivo Slider プラグインを使用しています。objectプラグインを使用すると、プラグインのプロトタイプのパラメーター内でいくつかのコールバックを提供できます。

$('.slider').nivoSlider({
    afterLoad: control_responses(this, false),
    beforeChange: control_responses(this, false),
    afterChange: control_responses(this, false)
});

に渡しthisたところcontrol_responses()、実際には の現在の反復を送信したいのですが、$('.slider')現在thisは を参照していwindow objectます。

$('.slider')の現在の反復をコールバック関数に渡すにはどうすればよいですか?

4

1 に答える 1

2

関数を呼び出してcontrol_responses、戻り値をオブジェクトに入れています。control_responsesコールバック関数が呼び出されたときに関数が呼び出されるように、オブジェクトに関数を配置します。

$('.slider').nivoSlider({
  afterLoad: function() { control_responses(this, false); },
  beforeChange: function() { control_responses(this, false); },
  afterChange: function() { control_responses(this, false); }
});
于 2012-09-03T11:37:02.353 に答える