당신은 이벤트와 함께 뭔가를 할 수 있으며, 콜백. 나는 아직도 당신이 에 의하여 의미하는 무슨을 "기능이 유효하게되었다"확실하지 않다, 그러나 여기 당신의 시작을 얻어야하는 나의 머리의 정상 떨어져 무언가는이다.
// Check if all conditions are complete.
function completionChecker(limit, callback) {
// Private count variable will outlast scope due to closure.
var count = 0;
// Return a callback for the event.
return function(event) {
if(++count == limit) {
// Call the callback supplied.
callback();
// Remove the event listener, we've reached the limit.
this.removeEventListener("finished", arguments.callee, false);
}
}
}
// Some function to perform when everything is complete.
function myFunc() { /* Do stuff */ }
// Create a custom event.
var myEvt = new CustomEvent("finished");
// Add a listener to the document. After 2 "finished" events, call myFunc.
document.addEventListener("finished", completionChecker(2, myFunc), false);
// Now in your ajax success callback, and wherever your other function
// has "become available", fire the "finished" event.
document.dispatchEvent(evt);
자바 스크립트 기능을 사용할 수있게된다는 것은 무엇을 의미합니까? 그걸 탐지하는 데 사용할 메커니즘은 무엇입니까? – RonaldBarzell
* 가능 * * 가능한 경우 다른 함수가 이벤트/콜백을 트리거해야합니다. – McGarnagle
slides.js를 사용하고 있으며 어떤 함수가 먼저 올지 알 수 없기 때문에 콜백을 사용할 수 없습니다. – user1082764