简体   繁体   English

在全日历活动中获取完整日期

[英]Get fulldate in fullcalendar eventDrop

How can I get fulldate of the specific position from eventDrop? 如何从eventDrop获取特定职位的完整日期?

Fulldate Example: 完整日期示例:

Current Position: 2013-12-20 当前位置: 2013-12-20

Dragged Position: 2013-12-11 拖曳位置: 2013-12-11

I want Dragged Position in '2013-12-11' form. 我想要“ 2013-12-11”表格中的“拖延位置”。 Is it possible ? 可能吗 ?

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

// ----- This Paramenter is Used for Draging Events ------ //   

eventDrop   : function(event, delta) {

       alert(delta);

// -- Right now its just providing days in '+' or '-'
// -- I want fulldate where it was dragged to: e.g 2013-12-11
}

Right now its just providing days in '+' or '-' . 现在,它只提供'+'或'-'的天数。

I want fulldate where it was dragged to: eg 2013-12-11 我想要将其拖到的完整日期:例如2013-12-11

Updated Answer (to get the modified date of the event) 更新的答案 (获取事件的修改日期)

The modified date of the event is stored in the event.start property of the event object that is passed into the eventDrop callback. 事件的修改日期存储在传递给eventDrop回调的事件对象的event.start属性中。 Basically, fullcalendar modifies the event object before invoking the callback. 基本上,fullcalendar在调用回调之前会修改事件对象。

Previous Answer (to get the original date of the event) 上一个答案 (获取活动的原始日期)

I haven't been able to find a way to directly access the original date from the eventDrop callback, since fullcalendar has already modified the event date. 由于fullcalendar已经修改了事件日期,因此我无法找到直接从eventDrop回调访问原始日期的方法。

I use the following workaround: 我使用以下解决方法:

(function() {    
   var originalDate;

   $('#calendar').fullCalendar({
      // Always called before eventDrop
      eventDragStart: function(event) {
         originalDate = new Date(event.start);  // Make a copy of the event date
      },

      eventDrop: function(event, dayDelta, minuteDelta) {
         alert( 'Event dropped!  Original date = ' + originalDate );
      }
   }
})();

As shown in the code, the idea is just to tuck away the original date in the eventDragStart callback that is guaranteed to be called before the event drop callback. 如代码中所示,其想法只是在eventDragStart回调中添加原始日期,该日期必须保证在事件drop回调之前被调用。

$(document).ready(function () { $(document).ready(function(){

eventDrop: function(event,revertFunc) { eventDrop:function(event,revertFunc){

var CurrentPositionDate= $.fullCalendar.formatDate(event.start, 'yyyy/MM/dd'); var CurrentPositionDate = $ .fullCalendar.formatDate(event.start,'yyyy / MM / dd');

} }); }});

Here currentPositionDate contain the date of current position date after drop event. 这里currentPositionDate包含放置事件之后当前位置日期的日期。

Just put this code in your script Its work for me....Thanks 只需将这段代码放在您的脚本中,对我来说就是...。谢谢

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM