我在Fullcalender.js上添加了关于事件的onclick事件。但是当我将日历视图从月份更改为周或日时,onclick事件不再起作用。请帮我解决这个问题。
这是我的代码在页面加载后的第一次,它完美地工作但在更改视图后点击不起作用:
<script>
$(document).ready(function () {
debugger;
$.ajax({
url: "/Appointment/GetAgendaList",
data: {userid:@Convert.ToInt32(Session["UserID"])},
dataType: "json",
type: "POST",
success: function (response) {
debugger;
//load all events
LoadEvents(response);
}
});
//Add click events on each Event link to get details
var clicks = 0;
$('td.fc-event-container a').on({
click: function (event) {
node = $(this);
clicks++;
if (clicks == 1) {
setTimeout(function () {
if (clicks == 1) {
$('#loderdiv').show();
var loadurl = $('input#hdneventdetailsurl').val();
var eventid = $(node).find('input.hdneve_id').val();
loadurl = loadurl + "/" + eventid;
$('#myagenda').load(loadurl, function () {
$('div#myagenda').modal('show');
$('#loderdiv').hide();
});
}
clicks = 0;
}, 300);
}
}
});
});
//Initialize the calender and add all events
function LoadEvents(data)
{
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '@DateTime.Now.ToString("yyyy-MM-dd")',
editable: true,
eventLimit: true, // allow "more" link when too many events
events:data
});
}