Fullcalendar:在上一次/下一次点击后保留事件属性 [英] Fullcalendar: Keep event properties after previous/next click

查看:523
本文介绍了Fullcalendar:在上一次/下一次点击后保留事件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:我使用Fullcalendar与agendaWeek视图。我需要做的是点击几周的事件(改变他们的颜色),然后点击下一个去到下一周,选择一些其他事件。



问题:每当我点击下一个旧事件(从前一周)都失去了我给他们的属性。例如,我更改其颜色并添加活动属性(自定义属性,以了解当前选择的事件)。这是我的代码

  $('#calendar')。fullCalendar({
defaultView:'agendaWeek',
header:{
left:'prev,next today',
center:'title',
right:'agendaWeek,agendaDay'
},
allDaySlot :false,
editable:false,
event:link_here,

eventClick:function(calEvent,jsEvent,view){
if(calEvent.active)
{

calEvent.active = false;

current_lessons = current_lessons.replace(calEvent.class_date + calEvent.class_id +$,'');
}

else
{
calEvent.title =clicked;

calEvent.active = true;
current_lessons + = calEvent.class_date + calEvent.class_id +$;
}
if($(this).hasClass('active'))
$(this).removeClass('active');
else $(this).addClass('active');

}
});

活动类用于为元素着色。所以再次发生的事情是,事件正在变得有色,他们正在获得一个新的属性的活动集为true,然后一旦我点击下一个回来,所有的事件是无色的,并有活性属性为假。

我如何解决这个问题?我搜索了很多,但没有找到我想要的。提前感谢。

解决方案

这个问题的解决方案,如果有人面对它是Fullcalendar,当使用JSON从URL生成的数据,每次使用next / previous再次访问另一周时,将从URL重新获取事件,因此将重置事件属性。解决方案是实际上有一个事件源的数组。我通过进入javascript文件和阅读部分代码发现了这一点。它尝试了一个数组,并没有导致相同的错误,虽然我尝试了一个小数组,我将尝试它在一个大型数据集,并看看是否是成功。


Goal: I am using Fullcalendar with the agendaWeek view. What I need to do is to click on a couple of events from a certain week (to change their color) and then click next to go to the following week and select a couple of other events.

Problem: Whenever I click next the old events (form the week before) are losing their properties that I give to them. For example, I change their color and add a property of active (custom property to know which events are currently selected). Here's my code

$('#calendar').fullCalendar({
  defaultView: 'agendaWeek',
  header: {
    left: 'prev,next today',
    center: 'title',
    right: 'agendaWeek,agendaDay'
  },
  allDaySlot:false,
  editable: false,
  events: link_here,

  eventClick: function(calEvent, jsEvent, view) {
    if(calEvent.active)
    {

      calEvent.active=false;

      current_lessons= current_lessons.replace(calEvent.class_date+calEvent.class_id+"$",'');
    }

    else
    {
      calEvent.title="clicked";

      calEvent.active=true;
      current_lessons+=calEvent.class_date+calEvent.class_id+"$";
    } 
   if($(this).hasClass('active'))
    $(this).removeClass('active');
  else $(this).addClass('active');

  }
});

The active class is used to color the elements. So again what is happening is that events are getting colored, they are gaining a new property of active set to true, then once I click on next and get back, all events are uncolored and have the active property as false.

How can I solve this problem? I searched a lot but did not find what I want exactly. Thank you in advance.

解决方案

The solution for this problem in case someone else faces it is that Fullcalendar, when working with a JSON generated data from URL, the events will be refetched from the URL each time you go to another week using next/previous, thus the event properties will be reset. The solution is to actually have an array for the event source. I discovered this by going into the javascript file and reading part of the code. It have tried it with an array and it did not result in the same error, though I tried it on a small array, I will try it on a large dataset and see if it is a success.

这篇关于Fullcalendar:在上一次/下一次点击后保留事件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆