0
는
여기가 방향에 따라이 이름 공간을 사용하여 jQuery를 플러그인을 구축하기 위해 노력하고있어 메서드,jQuery를 이름 간격과의 setTimeout
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 일이 일어날 등의 창없는 플러그인 객체에서 해고되고 난 플러그인 번 페이지 당보다 더에 사용할 수 원하는 것을있는 것은 그래서 난 그냥 저장할 수 없습니다 창에 현재 개체가 어떻게 이것을 달성 할 수 있습니까?
return this.each
의this
외부를 사용할 때하는 당신에게 정확한 선택을 결과를 줄 것이다 발견' this.moveLeft();'? 'self' (또는'$ this')를 사용하십시오. –고마워요.하지만 지금 알아 냈습니다. – HotHeadMartin
그런 다음 다른 사람에게 익숙하다고 생각하거나 질문을 삭제할 경우 답을 해결책으로 제공해주십시오. –