Javascript 标题:{ 左:“上一个,下一个今天”, 中心:'标题', 右图:“月,agendaWeek,agendaDay” }, displayEventTime:false, //事件:事件数组, dayClick:函数(日期、事件、视图){ $.ajax({ 类
标题:{ 左:“上一个,下一个今天”, 中心:'标题', 右图:“月,agendaWeek,agendaDay” }, displayEventTime:false, //事件:事件数组, dayClick:函数(日期、事件、视图){ $.ajax({ 类型:“POST”, contentType:“应用程序/json;字符集=utf-8”, url:“NewUserScore.aspx/GetScoreDetailsForDate”, 数据:“{'date':'”+date.format()+“,'userId':'“+user+”}”, 成功:功能(结果){ $(“#tblScore td”).remove(); var tblEmployee=$(“#tblScore”); $.each(result.d,函数(索引,项){ var tr=$(“”); tr.html((“编辑”) +“+”(“删除”) +“”+(“”+item.scoreDate+“”) +“”+(“”+item.uUser.struserName+“”) + " " + (" ") +“”+(“”+item.pProject.strProjectName+“”) ++(“+item.CaseScore+”); tblEmployee.append(tr); }); } }); }, }); //$(“#日历”).fullCalendar('gotoDate',date); });Javascript 标题:{ 左:“上一个,下一个今天”, 中心:'标题', 右图:“月,agendaWeek,agendaDay” }, displayEventTime:false, //事件:事件数组, dayClick:函数(日期、事件、视图){ $.ajax({ 类,javascript,fullcalendar,Javascript,Fullcalendar,标题:{ 左:“上一个,下一个今天”, 中心:'标题', 右图:“月,agendaWeek,agendaDay” }, displayEventTime:false, //事件:事件数组, dayClick:函数(日期、事件、视图){ $.ajax({ 类型:“POST”, contentType:“应用程序/json;字符集=utf-8”, url:“NewUserScore.aspx/GetScoreDetailsForDate”, 数据:“{'date':'”+date.format()+
可以通过api“NewUserScore.aspx/GetScoreDetailsForDate”添加页面和JSON对象返回的完整视图源代码,但情况不同。它只用于在单独的表中填充数据,而不是在完整的日历中。对事件的实际ajax调用是“NewUserScore.aspx/GetScoreDetails”。您不需要也不应该在每次按下搜索时重新初始化日历,只需重新获取事件,但为搜索传递不同的参数值。在“搜索”按钮回调之外声明日历一次,但将事件设置为动态回调函数-请参阅。然后,当您单击“搜索”按钮时,只需运行“refetchEvents”。fullCalendar将自动执行“事件”回调并从服务器获取新数据,而无需重新创建整个事件calendar@ADyson顺便说一下,$('日历').fullCalendar('销毁');完成了我想要的技巧,但我确实想应用重新获取事件的功能,如果我想使用后退和前进按钮。”,我应该将收集的事件数据传递给重新获取事件,如下所示:$(“#日历”).fullCalendar('refetchEvents',events)”。否,refetchEvents不接受任何事件作为参数。相反,如果将
events
设置为函数(根据我链接到的页面),则运行refetchEvents将导致该函数再次执行。在该函数中,将包含用于返回事件的ajax调用。此时,您可以轻松地将搜索字段中的当前值传递给ajax调用
<script>
$(document).ready(function () {
$("#searchBtn").click(function () {
var month = $('#ContentPlaceHolder2_DropDownMonth option:selected').val();
var user = $('#ContentPlaceHolder2_DDUser option:selected').val();
alert(month.split(" ")[0]);
var monthname = month.split(" ")[0];
var year = month.split(" ")[1];
var monthd = new Date(Date.parse(monthname + "1", year)).getMonth() + 1
var date = year + "-" + monthd + "-" + "1"
console.log(monthd)
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "NewUserScore.aspx/GetScoreDetails",
data: "{ 'userId':'" + user + "', 'month':'" + month + "'}",
success: function (result) {
events_array = [];
$.each(result.d, function (key, value)
{
if (value.start != null) {
events_array.push(
{
title: value.title,
start: value.start
});
}
});
console.log(events_array)
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: date,
displayEventTime: false,
events: events_array,
dayClick: function (date, jsEvent, view) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "NewUserScore.aspx/GetScoreDetailsForDate",
data: "{ 'date':'" + date.format() + "', 'userId':'" + user + "'}",
success: function (result) {
$("#tblScore td").remove();
var tblEmployee = $("#tblScore");
$.each(result.d, function (index, item) {
var tr = $("<tr></tr>");
tr.html(("<td> <button type=\"button\" id=" + item.Id + " class=\"btnEdit\" data-toggle=\"modal\" data-target=\"#dialog-transaction\">Edit</button> </td>")
+ " " + ("<td><button type=\"button\" id=" + item.Id + " class=\"btnDelete\">Delete</button></td>")
+ " " + ("<td>" + item.scoreDate + "</td>")
+ " " + ("<td>" + item.uUser.struserName + "</td>")
+ " " + ("<td><a href =\"Case.aspx?id=" + item.cCase.strId + "\" target=_blank>" + item.cCase.strTitle + "</a> </td>")
+ " " + ("<td>" + item.pProject.strProjName + "</td>")
+ " " + ("<td>" + item.CaseScore + "</td>"));
tblEmployee.append(tr);
});
}
});
},
});
$('#calendar').fullCalendar('gotoDate', date);
$('#calendar').fullCalendar('refetchEvents');
}
});
});
});
</script>
$("#searchBtn").click(function () {
var month = $('#ContentPlaceHolder2_DropDownMonth option:selected').val();
var user = $('#ContentPlaceHolder2_DDUser option:selected').val();
alert(month.split(" ")[0]);
var monthname = month.split(" ")[0];
var year = month.split(" ")[1];
var monthd = new Date(Date.parse(monthname + "1", year)).getMonth() + 1
var date = year + "-" + monthd + "-" + "1"
console.log(monthd)
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "NewUserScore.aspx/GetScoreDetails",
data: "{ 'userId':'" + user + "', 'month':'" + month + "'}",
success: function (result) {
events = [];
$.each(result.d, function (key, value)
{
if (value.start != null) {
events.push(
{
title: value.title,
start: value.start
});
}
});
console.log(events)
$("#calendar").fullCalendar('refetchEvents', events);
}
});
});
<script>
$(document).ready(function () {
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
displayEventTime: false,
//events: events_array,
dayClick: function (date, jsEvent, view) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "NewUserScore.aspx/GetScoreDetailsForDate",
data: "{ 'date':'" + date.format() + "', 'userId':'" + user + "'}",
success: function (result) {
$("#tblScore td").remove();
var tblEmployee = $("#tblScore");
$.each(result.d, function (index, item) {
var tr = $("<tr></tr>");
tr.html(("<td> <button type=\"button\" id=" + item.Id + " class=\"btnEdit\" data-toggle=\"modal\" data-target=\"#dialog-transaction\">Edit</button> </td>")
+ " " + ("<td><button type=\"button\" id=" + item.Id + " class=\"btnDelete\">Delete</button></td>")
+ " " + ("<td>" + item.scoreDate + "</td>")
+ " " + ("<td>" + item.uUser.struserName + "</td>")
+ " " + ("<td><a href =\"Case.aspx?id=" + item.cCase.strId + "\" target=_blank>" + item.cCase.strTitle + "</a> </td>")
+ " " + ("<td>" + item.pProject.strProjName + "</td>")
+ " " + ("<td>" + item.CaseScore + "</td>"));
tblEmployee.append(tr);
});
}
});
},
});
//$('#calendar').fullCalendar('gotoDate', date);
});
</script>