contextMenu打破FullCalendar事件拖动

contextMenu打破FullCalendar事件拖动

本文介绍了contextMenu打破FullCalendar事件拖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我最近使用jQuery contextMenu(http://abeautifulsite.net/blog/2008/09/jquery-context-menu-plugin/)为我的FullCalendar中的事件添加了一个上下文菜单。它的工作原理非常漂亮,除了我的拖/放功能停止正常工作,当您拖动一个事件并放过另一个日期时,事件日期不会改变,并且它会重定向到事件的URL。我做了一些检查,并意识到eventDrop,eventDragStart和eventClick都没有被解雇。如果我注释掉上下文菜单,一切正常。如果任何人都可以找出为什么contextMenu阻止fullCalendar回调被解雇,我会很感激,因为contextMenu完全适合我的需求。
contextMenu和事件回调代码:

  eventRender:function(event,element){
if( event.url.indexOf(https://www.google.com)!= 0)
{
element.contextMenu({
menu:myMenu,
},
function(action,el){
if(action ==approve){
$ .ajax({
url:'events /'+ event.id ,
data:{'event':{'status':Approved,}},
type:PUT,
}),
$('#calendar ').fullCalendar('refetchEvents');
} else if(action ==deny){
$ .ajax({
url:'events /'+ event.id,
data:{'event':{'status':Denied,}},
type:PUT,
}),
$('#calendar' ).fullCalendar('refetchEvents');
} else if(action ==destroy){
if(confirm(你确定你wa nt删除这个事件?)){
$ .ajax({
url:'events /'+ event.id,
type:DELETE,
}) ,
$('#calendar')。fullCalendar('refetchEvents');


else if(action ==edit){
window.location ='events /'+ event.id +'/ edit'
}
}
);


$ b eventDrop:function(event,dayDelta,minuteDelta,allDay,revertFunc){
updateEvent(event);
},

eventResize:function(event,dayDelta,minuteDelta,revertFunc){
updateEvent(event);
},

eventClick:function(event){
if(event.url.indexOf(https://www.google.com)!= 0){
$ .facebox(function(){
$ .get('events /'+ event.id,
function(data){
$ .facebox(data)
}
);
})
return false;
}
返回false;


解决方案

这是不会得到答案我的解决方案是切换到一个不同的上下文菜单插件(http://www.trendskitchens.co.nz/jquery/contextmenu/)这是非常相似,并没有导致任何问题与全日历。这不是解决这个插件与完整日历工作有关的任何问题的解决办法,但它是修复程序,让我的程序正常运行。


So I recently added a context menu to the events in my FullCalendar using jQuery contextMenu (http://abeautifulsite.net/blog/2008/09/jquery-context-menu-plugin/). It works beautifully, except that my dragging/dropping ability stopped working properly, when you drag an event and let go over another date the event date isn't changed, and it redirects to the event's url. I did some checking, and realized that eventDrop, eventDragStart, and eventClick all aren't being fired. If I comment out the context menu everything works fine. If anyone can figure out why contextMenu is preventing the fullCalendar callbacks from being fired I'd appreciate it, since contextMenu suits my needs perfectly otherwise.Code for contextMenu and event callbacks:

eventRender: function(event, element) {
    if (event.url.indexOf("https://www.google.com") != 0)
    {
      element.contextMenu({
        menu: "myMenu",
      },
      function(action, el) {
        if (action == "approve") {
          $.ajax({
            url: 'events/' + event.id,
            data: { 'event' : { 'status' : "Approved", } },
            type: "PUT",
          }),
          $('#calendar').fullCalendar('refetchEvents');
        } else if (action == "deny") {
          $.ajax({
            url: 'events/' + event.id,
            data: { 'event' : { 'status' : "Denied", } },
            type: "PUT",
          }),
          $('#calendar').fullCalendar('refetchEvents');
        } else if (action == "destroy") {
          if (confirm("Are you sure you want to delete this event?") ) {
            $.ajax({
                url: 'events/' + event.id,
                type: "DELETE",
            }),
            $('#calendar').fullCalendar('refetchEvents');
          }
        }
        else if (action == "edit") {
          window.location = 'events/' + event.id + '/edit'
        }
      }
      );
    }
  },

  eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc){
    updateEvent(event);
  },

  eventResize: function(event, dayDelta, minuteDelta, revertFunc){
      updateEvent(event);
  },

  eventClick: function(event) {
    if (event.url.indexOf("https://www.google.com") != 0) {
      $.facebox(function() {
        $.get('events/' + event.id,
          function(data) {
            $.facebox(data)
          }
        );
      })
      return false;
    }
    return false;
  }
解决方案

Well, since it looks like this isn't gonna get answered my solution was to switch to a different context menu plugin (http://www.trendskitchens.co.nz/jquery/contextmenu/) which was very similar and didn't cause any problems with Full Calendar. It's not a fix for whatever problem stops this plugin from working with Full Calendar, but it is a fix to get my program running properly.

这篇关于contextMenu打破FullCalendar事件拖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 17:16