2011-03-09 2 views
0

startChangeImage()와 같은 슬라이드 쇼를 회전시키는 함수가 있습니다. 슬라이드 쇼가 마우스 오버 될 때 내 슬라이드 쇼가 중지되어야합니다. 이dojo를 사용하여 특정 이벤트 리스너 이외의 함수를 실행합니다.

 
    dojo.connect(this.domNode,'onmouseover',this,this.stopChangeImage); 
        this.start = dojo.connect(this.domNode,'onmouseout',this,this.startChangeImage); 

..... 

stopChangeImage:function() { 
      dojo.disconnect(this.start); 

     } 


........ 

것은 같은

오전 노력 뭔가 그것이 내가 마우스 커서를 가져다 대면을 제외한 모든 시간에 작업 할 경우에만 마우스 아웃 후 회전을 시작합니다.

답변

2

onmouseout 이벤트를 startChangeImage()에 연결했기 때문에 이러한 현상이 발생합니다. 페이지가로드 될 때이 슬라이드 쇼를 시작하려면 페이지가로드되어 슬라이드를 느리게 시작할 때 호출되는 init() (또는 유사한) 함수가있을 수 있습니다.

dojo.connect()을 컨텍스트 (see here)와 함께 사용하는 경우에도 this.이 필요하지 않습니다. 아래 코드 샘플의 연결 함수를 참조하십시오. 페이지가로드,하지만 중지하고 마우스 오버와로 마우스를 기반으로 시작할 때

var pageClass = { 

    stopChangeImage: function() { }, 

    startChangeImage: function() { }, 

    init: function() { 

     this.startChangeImage(); 

     dojo.connect(this.domNode, 'onmouseover', this, 'stopChangeImage'); 
     this.start = dojo.connect(this.domNode, 'onmouseout', this, 'startChangeImage'); 
    } 

}; 

dojo.addOnLoad(function() { 

    pageClass.init(); 
}); 

위의 코드는 느린 슬라이드를 시작합니다.

+0

"this.start =" – mwilcox

+0

원래 예제에서 있었기 때문에 제거한 후 dojo.disconnect()와 함께 사용할 이벤트에 대한 링크를 제공합니다. – GreenWebDev