2013-08-22 7 views
3

jQuery 애니메이션이 완료되면 콜백 함수를 사용해야합니다. 나는 항상 이렇게했습니다 :jQuery 애니메이션 "완료"콜백에 대한 올바른 구문

그러나 질문을 할 때 나는 다른 구문을 가진 해결책을 제안했습니다.

$('#redirectNoticeContainer').animate({ properties }, { queue: false, duration: 123 }); 

는 내가 거기 콜백 함수를 넣어 하죠? 이것은 내 추측이지만 작동하지 않습니다.

$('#redirectNoticeContainer').animate({ properties }, { queue: false, duration: 123 }, function() { 
console.log("ok"); 
setTimeout(function() { window.location.replace("/Account/Login"); }, 1200); 
}); 

애니메이션이 작동합니다. 콜백은하지 않습니다. 어디로 넣어야합니까?

+0

http://api.jquery.com/ animate/ –

답변

12

That form of animate()complete 옵션을 취 JQuery와 이후

$("#redirectNoticeContainer").animate({ 
    // properties... 
}, { 
    queue: false, 
    duration: 123, 
    complete: function() { 
     console.log("ok"); 
     setTimeout(function() { 
      window.location.replace("/Account/Login"); 
     }, 1200); 
    } 
}); 
+0

나는 그걸 완전히 놓쳤다. 감사합니다, 그것은 작동합니다! – Saturnix

관련 문제