ajax Load처리후 ON 이벤트에서 다시 똑같은 ajax Load를 사용하기
달력을 불러오는 url이 있는데
거기서 다음달을 클릭하면
load()함수를 써서 불러오는데 다시 다음달 버튼을 클릭할려면 on()함수를 써서
똑같은 load page를 써야한다.
이럴때 약간 아리쏭한 일이 생각나서 소스를 구현해 본다.
// Top Calendar ajax Load ...
var v_top_calendar_wrap = $('#top_calendar_wrap');
var v_sel_cal_wrap = $('#sel_cal_wrap');
var v_scalendarGo = $('[id^="scalendarGo_"]');
var v_scalendarYmd = $('[id^="scalendarYmd_"]');
// 이전달 , 다음달 클릭시...
v_scalendarGo.click(function(event){
var v_Go_date = $(this).attr("id").replace('scalendarGo_','');
$.loadTopCalenar(v_Go_date);
event.preventDefault();
});
$.loadTopCalenar = function(seldate){
v_top_calendar_wrap.html("<DIV style="MARGIN: 0px auto; DISPLAY: table"><IMG alt=loading... src="http://godlvkhj.tistory.com/images/ajax-loader.gif"></DIV>");
v_top_calendar_wrap.load("/AjxAgent/loadTopCalenar.jsp", {seldate : seldate}, function(response, status, xhr) {
if (status == "error") {
var msg = "캘린더 정보불러오기 실패 : ";
alert(msg + xhr.status + " " + xhr.statusText);
}else{
if(v_sel_cal_wrap.css('display') == 'block') v_sel_cal_wrap.hide();
$("[id^='scalendarGo_']").on('click',function(event){
var v_Go_on_date = $(this).attr("id").replace('scalendarGo_','');
$.loadTopCalenar(v_Go_on_date);
event.preventDefault();
});
}
});
}