2014-06-12 4 views
1

클릭하면 처리기에서 작동하지 않는 코드 스쿨 jquery 과정과 관련된 이상한 문제가 발생합니다. 우리는 5.10에서 해결하려고하는 질문은 우선 들어codeschool jQuery Return 클릭 핸들러 실패시 5.10

가 .see - 사진 각 .tour 내에서 연결 대상에 사용하여 이벤트 핸들러를 만듭니다. 이 버튼을 클릭하면 투어에 is-showing-photofy 클래스를 추가하는 함수를 실행하십시오. 이벤트 핸들러 외부의 참조를 저장하고 click 이벤트 핸들러에서 사용하는 것이 좋습니다.

$.fn.photofy = function() { 
    this.each(function() { 
     var tour = $(this) 
    tour.on('click.see-photos', 'button', function() { 
     $(this).addClass('is-showing-photofy'); 
    }); 
    }); 
} 

$(document).ready(function() { 
    $('.tour').photofy(); 
}); 

내가 무엇입니까 오류 메시지는 다음과 같습니다 :

내 현재 코드 시도는

Your `on` `click` handler should watch for clicks on the `.see-photos` element within the current tour 

는 사람이 올바른 방향으로 날 포인트?

답변

2

나는 다음과 없어진 :

  • 을 방지 기본을
  • VAR 투어 = $ (이)

최종 코드 :

$.fn.photofy = function() { 
    this.each(function() { 
     var tour = $(this); 
    tour.on('click.photofy', '.see-photos', function(event) { 
     event.preventDefault(); 
     tour.addClass('is-showing-photofy'); 
    }); 
    }); 
} 

$(document).ready(function() { 
    $('.tour').photofy(); 
}); 
관련 문제