jquery - 带资源的全日历年 View

标签 jquery fullcalendar

我们需要使用资源构建年 View 日历。但我们无法做到这一点,因为事件的焦点没有转移到其他月份,甚至事件在各自的位置上也没有约束力。谁能提供使用资源构建年 View 日历的解决方案?

我们在使用资源构建年 View 日历时引用了此链接:

http://tux.fi/~jarnok/fullcalendar-resourceviews/

最佳答案

我们仅通过创建自定义月份属性并迭代日历 12 次就实现了这一目标。我们创建了 12 个 div。每个div都会绑定(bind)一个日历。 这是代码

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

        for (var i = 0; i < 12; i++) {
            calendar[i] = $("div[id='calendar" + i + "']").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,
                monthno: i,  //custom property
                selectHelper: true,
                resources: [{ "name": "Resource 1", "id": "resource1" },
              { "name": "Resource 2", "id": "resource2" },
              { "name": "Resource 3", "id": "resource3" },
              { "name": "Resource 4", "id": "resource4" }
              ],
                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: 'resource1'
            },
            {
                title: 'Meeting',
                start: new Date(y, m, d, 10, 30),
                end: new Date(y, m, d + 4, 11, 00),
                allDay: false,
                resource: 'resource1'
            },
                {
                    title: 'All Day Event',
                    start: new Date(y, m, 1),
                    resource: 'resource2'
                }
        ],
                dayClick: function (date, allDay, jsEvent, view) {
                    alert(date);
                },
                select: function (start, end, allDay, jsEvent, view, resource) {
                    var title = prompt('event title:');
                    if (title) {
                        calendar[start.getMonth()].fullCalendar('renderEvent',
                    {
                        title: title,
                        start: start,
                        end: end,
                        allDay: allDay,
                        resource: resource.id
                    },
                    true // make the event "stick"
                );
                    }
                    calendar[start.getMonth()].fullCalendar('unselect');
                },
                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 clicked');
                }                  
            });
        }         

 ---------------------------



<div id="mainContainer">

 <h2>Calendar Demo</h2>
  <div class="fc fc-ltr" id="calendar0" month="0" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar1" month="1" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar2" month="2" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar3" month="3" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar4" month="3" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar5" month="3" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar6" month="3" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar7" month="3" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar8" month="3" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar9" month="3" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar10" month="3" style="font-size:13px"></div>
  <div class="fc fc-ltr" id="calendar11" month="3" style="font-size:13px"></div>
  </div>

关于jquery - 带资源的全日历年 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21424814/

相关文章:

javascript - 使用来自 ajax 的 javascript 和 php 编辑表中的数据

jquery - 使用 jQuery FullCalendar 的非公历日历

javascript - 使用模态 Bootstrap 在 Fullcalendar 中编辑事件

javascript - 更改完整日历中单元格的颜色

javascript - 全日历月 View 中下个月的开始日和结束日

PHP、ajax 和 JQplot

javascript - 当所有 div 具有相同的类时,如何检索单个文本值

javascript - jquery id 选择器与变量

javascript - 用于单个事件的 Bootstrap Fullcalendar 模态

jquery - rails 4- 401未经授权的错误处理