ここの方向に従って名前間隔を使用してjQueryプラグインを構築しようとしています: http://docs.jquery.com/Plugins/Authoring#Namespacing
今、プラグインが setTimeout を使用してそのメソッドの 1 つを起動する必要があるという問題に遭遇しました。
var jScrollerMethods = {
ready:function(){
return this.each(function(){
var self = this,
$this = $(this),
data = $this.data('jScroller');
settings.timeoutHandle = setTimeout(function(){
if(settings.direction = "left"){
this.moveLeft();
}else if(settings.direction = "right"){
this.moveRight();
}
}, settings.time);
$this.data('jScroller', {
settings: settings,
element: this
});
});
}
$.fn.jScroller = function(call){
if ( jScrollerMethods[call] ) {
return jScrollerMethods[call].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof call === 'object' || ! call ) {
if (call) { $.extend(settings, call); }
return jScrollerMethods.init.apply( this, call );
} else {
$.error( 'Method ' + call + ' does not exist on jQuery.jScroller' );
}
}
しかし、私が起こるように、setTimeoutはプラグインオブジェクトではなくウィンドウから起動され、プラグインをページごとに複数回使用できるようにしたいので、現在のオブジェクトをウィンドウに保存することはできません。どうすればこれを達成できますか?