简体   繁体   English

仅加载资源。 活动在FullCalendar中不起作用

[英]Resources only loaded. Events not working in FullCalendar

I have been working on scheduler and found that full calendar could be a good solution to me. 我一直在研究调度程序,发现完整的日历可能对我来说是一个很好的解决方案。 I have loaded resources and event with values that came up with the code. 我已经用代码附带的值加载了资源和事件。 But, When I grab resources from my database, event stopped working. 但是,当我从数据库中获取资源时,事件停止了工作。

Here is my code: 这是我的代码:

<style type='text/css'>

    #calendar {
        width: 100%;
        }

</style>

<script type='text/javascript'>

    $(document).ready(function() {

        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        var calendar = $('#calendar_resources').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'resourceDay,resourceWeek,resourceNextWeeks,resourceMonth'
            },
            defaultView: 'resourceMonth',
            firstDay: 1,    
            editable: true,
            selectable: true,
                    minTime: 8,
        maxTime:16,
            selectHelper: true,
            events: [
                {
                    title: "Lunch 12.15-14.45",
                    start: new Date(y, m, d, 12, 15),
                    end: new Date(y, m, d, 14, 45),
                    allDay: false,
                    resource: 1
                },              
                {
                    title: 'Meeting from this day to this +4',
                    start: new Date(y, m, d, 10, 30),
                    end: new Date(y, m, d+4, 11, 00),
                    allDay: false,
                    resource: 1
                },
                {
                    title: 'Meeting 11.00',
                    start: new Date(y, m-2, d, 11, 00),
                    allDay: true,
                    resource: 2
                },
                {
                    title: 'Lunch 12-14',
                    start: new Date(y, m, d, 12, 0),
                    end: new Date(y, m, d, 14, 0),
                    allDay: false,
                    resource: 3
                }       
            ],
            resources: base_url+'admin/allocations/load_resources/<?php echo $product_id; ?>',
            select: function(start, end, allDay, jsEvent, view, resource) {
                var title = prompt('event title:');

                if (title) {
                    calendar.fullCalendar('renderEvent',
                        {
                            title: title,
                            start: start,
                            end: end,
                            allDay: allDay,
                            resource: resource.id
                        },
                        true // make the event "stick"
                    );
                }
                calendar.fullCalendar('unselect');
            },
            resourceRender: function(resource, element, view) {
                // this is triggered when the resource is rendered, just like eventRender
            },
            eventDrop: function( event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view ) { 
                alert('event moved to '+event.start+' to '+event.resource);
            },
            eventResize: function( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) { 
                alert('event was resized, new endtime: '+event.end);
            },
            eventClick: function ( event, jsEvent, view )  {
                alert('event '+event.title+' was left clicked');
            },
            eventRender: function( event, element, view ) { 

            },
            windowResize: function( view ) {
                calendar.fullCalendar('option', 'height', $(window).height() - 40);
            }
        });
    });

</script>



<div id='calendar_resources'></div>
<div id='contextMenuContainer' style='background-color:#f0f0f0;width:100px;height:100px;display:none;z-index:999;border-radius:5px;border:1px solid black;position:absolute;'></div>

I am stuck at this place. 我被困在这个地方。 I am not able to get events in my calendar. 我无法在日历中获取事件。 Helping hands are appreciated. 伸出援助之手。

I've made an issue on that, to be able to change the resources source on the fly ( https://github.com/jarnokurlin/fullcalendar/issues/11#issuecomment-38090185 ), for now, I've just hard changed the core: 我对此提出了一个问题,以便能够即时更改资源来源( https://github.com/jarnokurlin/fullcalendar/issues/11#issuecomment-38090185 ),就目前而言,我很难改变了核心:

function fetchResources(useCache, currentView) {
    // if useCache is not defined, default to true
    useCache = typeof useCache !== 'undefined' ? useCache : true;

    if (cache != undefined && useCache) {
        // get from cache
        return cache;
    } else {
        // do a fetch resource from source, rebuild cache
        cache = [];
        /** TWEAK BY HAKS **/

        var resources = _fetchResourceSource({url: "/projetcollaborateur/findProjCollabs?proj=" + $("#selectCalProj option:selected").val()}, currentView);
        cache = cache.concat(resources);
        /*
        var len = sources.length;
        for (var i = 0; i < len; i++) {
            var resources = _fetchResourceSource(sources[i], currentView);
            cache = cache.concat(resources);
        }*/
        /** END TWEAK **/
        return cache;
    }
}

Also, be aware that events seems to be loaded before the resources (and this is what I'm trying to change for my app... ) 另外,请注意,事件似乎是在资源之前加载的(这就是我要为我的应用程序更改的内容...)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数据库中的资源和事件显示到 fullcalendar? - How to dispaly resources and events from database to fullcalendar? fullcalendar v 2 php事件不起作用 - fullcalendar v 2 php events not working FullCalendar-仅加载日期之间的事件 - FullCalendar - only load events between dates FullCalendar-仅请求当月的事件 - FullCalendar - Only request events for current month 尝试从mysql获取数据,但每个字段仅加载第一个字符。 在本地工作,但不在线 - Trying to fetch data from mysql but only the first character for each field is loaded. Works Locally but not online 404.路由不起作用,但是登录页面正在起作用。 样式文件未加载。 Symfony的 - 404. The routing does not work, but the landing page is working. Styles files are not loaded. Symfony 使fullcalendar仅显示已登录用户的事件,而不是所有用户的事件 - Make fullcalendar only show events for logged in user not all users FullCalendar.io 事件无法通过 PHP 加载,FullCalendar 尝试解析 PHP 脚本的内容而不是其输出 - FullCalendar.io events can't be loaded through PHP, FullCalendar tries to parse the contents of the PHP script instead of its output fullcalendar:只有在我通过事件 function 加载我的事件后,才可以调用 dayRender - fullcalendar: is there a way to call dayRender only after i load my events via events function 全日历显示活动在一天点击 - FullCalendar display events on dayClick
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM