嗨,这里我想从div中删除数据并将新数据重新绑定到该div。 我怎样才能实现这一点。在div标签中我可以通过一些事件来展示完整的日历。 在这里,我想删除该div的数据并将新事件重新绑定到相同的div标签
$.ajax({
type: "POST",
contentType: "application/json",
data: dataString,
url: "ViewEvents.aspx/GetState",
dataType: "json",
success: function (data) {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
//select: selectDate,
eventClick: updateEvent,
droppable: false,
draggable: false,
disableDragging: true,
timeFormat: 'H:mm',
selectable: true,
selectHelper: true,
eventTextColor: 'Yellow',
eventBackgroundColor: 'purple',
events:
$.map(data.d, function (item, i) {
// $('#calendar').fullCalendar('addEventSource', item);
var sdate = item.StartDate
var sdatesplit = sdate.split("/");
var sm = sdatesplit[0];
var sm = sm - 1;
var sd = sdatesplit[1];
var sy = sdatesplit[2];
var syearsplit = sy.split(" ");
var edate = item.EndDate;
var edatesplit = edate.split("/");
var em = edatesplit[0];
var em = em - 1;
var ed = edatesplit[1];
var ey = edatesplit[2];
var eyearsplit = ey.split(" ");
var stime = item.EventStarttime;
var stimesplit = stime.split(":");
var etime = item.EventEndtime;
var etimesplit = etime.split(":");
var event = new Object();
event.id = item.EventID;
event.start = new Date(syearsplit[0], sm, sd, stimesplit[0], stimesplit[1]);
event.end = new Date(eyearsplit[0], em, ed, etimesplit[0], etimesplit[1]);
event.title = item.EventName;
event.allDay = false;
return event;
})
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger;
}
});
答案 0 :(得分:0)
答案 1 :(得分:0)
您可以按$('#calendar').html("");
清除网格。要重新绑定网格,您可以使用
$('#calendar').append('yourelements')` or
$('#calendar').add('yourelements')
`