Bootstrap fullcalendar不允许我调整事件的大小(光标不显示,我做错了)

o0lyfsai  于 2023-04-27  发布在  Bootstrap
关注(0)|答案(5)|浏览(100)

嗨,堆栈跟踪bug追逐者,我在这里寻求帮助......我在symfony2上,使用twitter bootstrap,我拼命尝试通过JSON调整发送到日历的元素的大小,通过以下方式,我可以拖动事件,但不能调整它们的大小......:
截图:http://nimga.fr/f/oDrdH.png
进入控制器:

foreach($events as $event) {

    $start = $event - > getDate();
    $allDay = ($event - > getLength() >= 8);
    $newevent = array('title' = > $event - > getTask() - > getName(),
        'start' = > $start - > format('Y-m-d H:i:s'),
        'id' = > $event - > getId(),
        'allDay' = > $allDay,
        'end' = > $start - > modify('+'.$event - > getLength().
            ' hour') - > format('Y-m-d H:i:s'));
    $eventsArray[] = $newevent;
}
return $this - > render('IntranetTimesheetBundle:Task:displayall.html.twig', array('htmlTree' = > $htmlTree, 'eventlist' = > json_encode($eventsArray)));

并在视图中:

$('#calendar').fullCalendar({
    droppable: true, // this allows things to be dropped onto the calendar !!!
    weekends: false, // will hide Saturdays and Sundays
    defaultView: 'agendaWeek',
    slotMinutes: 60,
    minTime: 7,
    maxTime: 19,
    events: {
        {
            eventlist | raw
        }
    },
    editable: true,
    resizable: true,
    eventDrop: function (event, dayDelta, minuteDelta, allDay, revertFunc) {
        var DATA = {
            "event_title": event.title,
            "event_id": event.id,
            "event_date": event.start,
            "dayDelta": dayDelta,
            "minuteDelta": minuteDelta,
            "allDay": allDay
        };
        $.ajax({
            type: "POST",
            url: "move",
            data: DATA,
            cache: false,
            success: function (data) {
                //to do in case of success
            }
        });
    },
    eventResizeStart: function (event, jsEvent, ui, view) {
        console.log('RESIZE START ' + event.title);

    },
    eventResizeStop: function (event, jsEvent, ui, view) {
        console.log('RESIZE STOP ' + event.title);

    },
    eventResize: function (event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view) {
        console.log('RESIZE!! ' + event.title);
        console.log(dayDelta + ' days'); //this will give the number of days you extended the event
        console.log(minuteDelta + ' minutes');

    }
})

我得到了jQuery,它的UI和droppable扩展加载,仍然没有箭头光标,以表明我可以调整事件。

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<link rel='stylesheet' type='text/css' href="http://arshaw.com/js/fullcalendar-1.6.4/fullcalendar/fullcalendar.css" />
<link rel='stylesheet' type='text/css' href="http://cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.print.css" />
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.min.js"></script>
frebpwbc

frebpwbc1#

最后,我找到了解决方案:将allDay添加到每个事件!

var event = {
    start: startEvent,
    end: endEvent,
    title: "Test",
    allDay: true
}
mjqavswn

mjqavswn2#

好吧,我刚刚发现问题出在哪里了:“fullcalendar.print.css”覆盖基本的“fullcalendar.css”,并在“display:没有”所以用css擦除打印,它起作用了。谢谢阅读。

e0uiprwp

e0uiprwp3#

只有长事件可调整大小。该事件没有时间沿着日期。示例:

events: [
    {
        title: 'All Day Event',
        start: '2014-06-01'
    },
    {
        title: 'Long Event',
        start: '2014-06-07',
        end: '2014-06-10'
    },
    {
        id: 999,
        title: 'Repeating Event',
        start: '2014-06-09T16:00:00'
    },
    {
        id: 999,
        title: 'Repeating Event',
        start: '2014-06-16T16:00:00'
    },
    {
        title: 'Meeting',
        start: '2014-06-12T10:30:00',
        end: '2014-06-12T12:30:00'
    },
    {
        title: 'Lunch',
        start: '2014-06-12T12:00:00'
    },
    {
        title: 'Birthday Party',
        start: '2014-06-13T07:00:00'
    },
    {
        title: 'Click for Google',
        url: 'http://google.com/',
        start: '2014-06-28'
    }
]
czq61nw1

czq61nw14#

您可以添加allDay:为每个事件设置True,或者在日历属性中设置allDayDefault={true}。它也会这样做。
希望能帮上忙。

5anewei6

5anewei65#

你可以使用方法。

calendarOptions: CalendarOptions = {
  eventResize: this.resizeCalendarEvent.bind(this)
}
function resizeCalendarEvent(event){
  console.log('event:', event)
}

相关问题