사용자 지정 경고 대화 상자를 만들고 상자 스타일이 올바르지 만 삽입 한 Ok 단추가 응답하지 않습니다. 아래는 참조 할 코드입니다.경고 대화 상자 사용자 지정 - 확인 단추가 응답하지 않습니다.
function CustomAlert(){
this.render = function(dialog){
...
...
document.getElementById('dialogboxfoot').innerHTML = "<button onclick = 'Alert.ok()'>OK</button>";
}
this.ok = function(){
document.getElementById('dialogbox').style.display = "none";
document.getElementById('dialogoverlay').style.display = "none";
}
}
var Alert = new CustomAlert();
$('#button1').click(function(){
Alert.render("Heyooo!!!");
})
Alert.render 함수가 올바르게 실행됩니다. (innerHTML 함수로 삽입 된) Alert.ok 함수를 트리거하려고하면 "Uncaught ReferenceError : Alert is not defined"라는 DOCTYPE 선언 인 index.html 파일의 라인 1을 참조합니다.
이 컨텍스트에서 호출 할 때 "경고"가 정의되지 않은 이유는 무엇입니까?
아마도 Alert가 범위에 있지 않기 때문에 ... –