javascript/asp.net에서 달력을 작성합니다.자바 스크립트 루프에서 ASP.NET Webservice를 호출하면 문제가 발생합니다.
캘린더를 인쇄 할 때 표시 할 항목 (약속)이 있는지 매일 확인하고 싶습니다. 다음은 함수의 일부입니다.
for (var i = 1; i <= monthdays[month - 1]; i++) {
curnum++;
td = tr.insertCell(-1);
td.style.height = "95px";
td.style.width = "131px";
html = "<div id=\"divday" + year + "" + month + "" + i + "\" style=\"position:relative; left:0px; top:0px; width130px; height:95px; background-color:" + colors[i % 2] + "; cursor:pointer; \" onclick=\"openDay(" + year + "," + (month < 10 ? "0" + month : month) + "," + (i < 10 ? "0" + i : i) + ")\">";
html += "<div class=\"blackl\" style=\"position:absolute; left:100px; top:0px; width:30px; height:20px; text-align:right; \">" + i + "</div>";
html += "</div>";
td.innerHTML = html;
if (curnum == 7) {
tr = tbl.insertRow(-1);
curnum = 0;
}
if(i == 1) RCalendar.GetCalendarEvents(agentid, year, month, i, function (result) { setCalendarEvents(year, month, i, result) });
마지막 줄에는 if (i == 1) 디버깅 전용이 없어야합니다. 나는 webservice를 호출하고 evert 하루 (i)에 대한 항목을 작성하고 싶습니다. 여기
콜백 함수이다function setCalendarEvents(y, m, d, result) {
var daydiv = document.getElementById("divday" + y + m + d);
for(var i = 0; i < result.length; i++) {
var thiscalendaritem = result[i];
daydiv.innerHTML += makeCalendarItem(thiscalendaritem);
}
}
I는 웹 서비스 호출과 callbackfunction에서, I 및 D는 동일하지 않은 중단 넣으면. 호출 될 때 나는 분명히 1이지만 enCoked 될 때 setCalendarEvents에서 d는 31입니다.
매일 매일 대신 서버에서 모든 이벤트를 가져 오는 것에 대한 첫 번째 설명은 의미가 있었고 다음과 같이 수정했습니다. (day-divs를 그리는 루프 이후 ...) 'getAllCalendarItemsInMonth (agentid, year, month); } 함수 getAllCalendarItemsInMonth (에이전트 ID, 연도, 월) { RCalendar.GetAllCalendarItemsInMonth (agentid, year, month, setAllCalendarItemsInMonth); } 'divday + datestring도 감사하지만이 캘린더는 한 번에 한 달씩 만 표시하므로 중요한 문제는 아닙니다. – Jesper