【问题标题】:contextMenu breaking FullCalendar event draggingcontextMenu 打破 FullCalendar 事件拖动
【发布时间】:2011-08-12 18:26:52
【问题描述】:

所以我最近使用 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("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;
  }

【问题讨论】:

    标签: jquery ruby-on-rails contextmenu fullcalendar


    【解决方案1】:

    好吧,因为看起来这不会得到回答,我的解决方案是切换到一个不同的上下文菜单插件 (http://www.trendskitchens.co.nz/jquery/contextmenu/),它非常相似并且没有对完整日历造成任何问题。对于阻止此插件与完整日历一起使用的任何问题,它都不是解决方案,但它是让我的程序正常运行的解决方案。

    【讨论】:

      【解决方案2】:

      对于那些不想更改插件的人,为了解决上下文菜单破坏可拖动性的问题,我修改了 jquery.contextMenu.js

      发件人:

      $(this).mousedown( function(e) {
                      var evt = e;
                      evt.stopPropagation();
                      $(this).mouseup( function(e) {
                          e.stopPropagation();
                          var srcElement = $(this);
                          $(this).unbind('mouseup');
                                                  if (evt.button == 2) {
      

      $(this).mousedown( function(e) {
                      var evt = e;
                      evt.stopPropagation();
                      $(this).mouseup( function(e) {
                          if (evt.button == 2) {
                              e.stopPropagation();
                              var srcElement = $(this);
                              $(this).unbind('mouseup');
      

      这会阻止上下文菜单插件在左键单击时执行任何操作,仅在右键单击时。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-08-16
        • 2022-01-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-26
        • 1970-01-01
        相关资源
        最近更新 更多