자바 스크립트에서 '리스너'유형 (Facebox) 내에서 일부 변수에 액세스해야합니다. 자바 스크립트 함수와 이벤트 리스너간에 변수를 전달하려면 어떻게해야합니까?자바 스크립트에서 이벤트 리스너 내 변수에 액세스하는 방법
범위와 관련하여 다소 혼란 스럽지만 글로벌 변수 선언이 조금 엉뚱한 것 같습니다. 특히 다른 컨트롤 (예 : 모달 내 결과에 대한 페이지 매김)을 고려하면 글로벌 변수만큼이나.) (당신이 사용한 예에서
function song_clarify()
{
// this launches a modal window, fills with html.
$.facebox('<div id="search"><div></div></div>');
}
// AJAX function. when called, this loads the required htmls into the modal
function clarify_loader()
{
var loadUrl = "ajax/clarify";
$("#search > div")
.html(ajax_load)
.load(loadUrl, 'search='+source+'&searchTerm='+song);
}
// Waits for the modal to be revealed before calling AJAX function.
// (if function called outside listener, nothing for the AJAX to bind to as modal appears dynamically)
$(document).bind('reveal.facebox', function() {
// Problem is here. Need to be able to do clarify_loader(source,song)
clarify_loader();
})
출처와 노래는 어디에서 왔습니까? 노래와 검색을 입력하는 사용자라면 html에서 가져올 수 있습니다. – ika