我有一个带有周视图的Fullcalendar。
我修改了完整的日历,显示了一个事件编号:
function slotSegHtml(event, seg) {
[...]
html +=
" class='" + classes.join(' ') + "'" +
" style='position:absolute;z-index:8;top:" + seg.top + "px;left:" + seg.left + "px;" + skinCss + "'" +
">" +
"<span class='fc-event-inner fc-event-qty'>"+htmlEscape(event.qty)+"</span>"+
[...]
return html;
}
在投递功能中:
drop: function(date, allDay) { // this function is called when something is dropped
// retrieve the dropped element's stored Event Object
var originalEventObject = $(this).data('eventObject');
// we need to copy it, so that multiple events don't have a reference to the same object
var copiedEventObject = $.extend({}, originalEventObject);
// assign it the date that was reported
copiedEventObject.id = idevento++;
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
copiedEventObject.className = 'newEvent';
copiedEventObject.qty = '1';
//buscar eventos
var listevents = $('#calendar').fullCalendar('clientEvents',function(event) {
if(date.getFullYear()!=event.start.getFullYear())return false;
if(date.getMonth()!=event.start.getMonth())return false;
if(date.getDay()!=event.start.getDay())return false;
if(date.getHours()!=event.start.getHours())return false;
//aparte tienen que ser del mismo tipo
if(event.title!=copiedEventObject.title)return false;
return true;
});
if(typeof listevents === 'object'){
//augmentar la cantidad
eventoantiguo = listevents[0];
copiedEventObject.qty = parseInt(eventoantiguo.qty)+1;
//borrar el objeto antiguo
$("#calendar").fullCalendar('removeEvents', eventoantiguo.id);
}
// render the event on the calendar
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
// is the "remove after drop" checkbox checked?
if ($('#drop-remove').is(':checked')) {
// if so, remove the element from the "Draggable Events" list
$(this).remove();
}
},
但当我在同一天和同一小时内放弃第二个事件时,所有事件都会消失。
对不起我的英语。
我认为责任线是:$('#calendar').fullCalendar('nderEvent',copiedEventObject,true);
萤火虫说:未捕获的类型错误:对象2没有方法"替换"
在这个功能
function htmlEscape(s) {
return s.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/'/g, ''')
.replace(/"/g, '"')
.replace(/n/g, '<br />');
}
(fullcalendar.js)
使用完整日历的事件限制,假设你想对一天的所有事件进行分组,那么只需将事件的限制设置为1,如下所示:
$('#divCalendar').fullCalendar({
theme: true,
eventLimit: true, // for all non-agenda views
eventLimit: 1,
......
further code
我用这行解决了问题:
copiedEventObject.qty = (parseInt(eventoantiguo.qty)+1)+'';//se tiene que convertir a string!
因为函数"function htmlEscape(s){"s"必须是字符串
谢谢!