2
단추 클릭에 문제가 있습니다 (FullCalendar
사용).Fullcalendar 모달 버튼 클릭 횟수가 더 늘어납니다.
내 계획은 다음과 같습니다 이벤트에
- 클릭
- 모달
- 확인은 MySQL 데이터베이스에 값을 변경 3 개 가지 옵션이 나타납니다/쓰레기는 MySQL 데이터베이스에 값을 변경
한 번 시도하면 잘 작동합니다. 하지만 모달을 닫고 다른 사람을 열면 거부/확인 버튼을 클릭하면 더 많은 시간 (2, 4 ...)이 실행됩니다. 무엇이 문제입니까 ??
모달 :
<div id="eventContent" title="Event Details" style="display:none;">
Name: <span id="name"></span><br>
Start: <span id="startTime"></span><br>
End: <span id="endTime"></span><br><br>
<p id="eventInfo"></p>
<button id="confirm_button" type="button">Confirm</button>
<button id="refuse_button" type="button">Refuse</button>
<button type="close_button">Close</button>
</div>
eventRender :
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: '',
center: 'prev title next',
right: ''
},
events: "http://localhost/calendar_directory/calendar_db_connect.php",
eventRender: function (event, element) {
element.click(function() {
var start = $.fullCalendar.formatDate(event.start, "YYYY-MM-DD");
var end = $.fullCalendar.formatDate(event.end, "YYYY-MM-DD");
$("#name").html(event.title);
$("#startTime").html(start);
$("#endTime").html(end);
$("#eventContent").dialog({modal: true, title: event.title, width: 350});
$("#refuse_button").click(function()
{
var id = event._id;
var confirmed_number = 2;
var decision = confirm("Do you really want to refuse that?");
if (decision)
{
$.ajax({
url: "http://localhost/calendar_directory/confirm_events.php",
data: '&id=' + id + '&confirmed_number=' + confirmed_number,
type: "POST",
success: function (json)
{
console.log(id);
return;
}
});
}
});
$("#confirm_button").click(function()
{
var id = event._id;
var confirmed_number = 1;
var decision = confirm("Do you really want to confirm that?");
if (decision)
{
$.ajax({
url: "http://localhost/calendar_directory/confirm_events.php",
data: '&id=' + id + '&confirmed_number=' + confirmed_number,
type: "POST",
success: function (json) {
console.log("confirmed");
return;
}
});
}
})
});
},
});
});
</script>
확인 열 수 있습니다 : 0,1 또는 클릭 이벤트에 동일한 처리기 할당
주의 : 모든 클릭 반복됩니다. 1, 모달 표시 -> 쓰레기통 클릭 -> 쓰레기통 확인 -> 닫기 2, 모달 표시 -> 쓰레기통 클릭 -> -> 거절 확인 -> 쓰레기통 확인 -> 닫기, 3, 모달 표시 -> 클릭 쓰레기 -> 쓰레기통 -> 폐기물 쓰레기통 -> 폐기물 쓰레기통 -> 쓰레기통, – danielori