저는 소수의 사람들과 함께 작은 웹 앱을 만들고 있습니다. 다른 개발자가 문서가 준비 될 때 항상 호출되는 몇 가지 기능을 정의 할 수있게하려고합니다.자바 스크립트 글로벌 콜백 함수가 호출되지 않았습니까?
Utils.funcs['start'] = function(){
alert('Starting...');
};
Utils.funcs['finish'] = function(){
alert('Finishing...');
};
: 별도의 .js 파일에서 개발자가 다음을 수행 할 수 있어야
<script type="text/javascript">
(function(){
window.Utils = {
funcs: {}
};
$(document).ready(function(){
alert('Calling funcs...');
var startFunc = Utils.funcs['start'];
if (startFunc != undefined){
startFunc();
}
var finishFunc = Utils.funcs['finish'];
if (finishFunc != undefined){
finishFunc();
}
});
})();
</script>
다음 :
우리의 응용 프로그램은 모든 페이지의 HTML 본문에 다음 스크립트를 삽입
하지만 이것은 작동하지 않습니다. 함수는 호출되지 않습니다?
jsFiddle 링크 : http://jsfiddle.net/XvQtF/