Getting id from eventReceive

前端 未结 1 1241
暗喜
暗喜 2020-12-21 16:43

I\'m trying to get the id attribute value from my div and put in calendar. I\'ve tried many ways without success.

I have the following

1条回答
  •  爱一瞬间的悲伤
    2020-12-21 16:57

    The event data needs to be valid JSON according to eventReceive documentation, so double quotes inside the data-event:

    My Event 1

    Sample https://jsfiddle.net/5wgoodwp/1/ :

    /* Edited from http://fullcalendar.io/js/fullcalendar-2.5.0/demos/external-dragging.html */
    

    HTML

    Draggable Events

    My Event 1

    JS

    /* initialize the external events
            -----------------------------------------------------------------*/
    
    $('#external-events .fc-event').each(function() {
    
      // make the event draggable using jQuery UI
      $(this).draggable({
        zIndex: 999,
        revert: true, // will cause the event to go back to its
        revertDuration: 0 //  original position after the drag
      });
    
    });
    
    
    /* initialize the calendar
    -----------------------------------------------------------------*/
    
    $('#calendar').fullCalendar({
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
      },
      editable: true,
      droppable: true, // this allows things to be dropped onto the calendar
      drop: function() {
        $(this).remove();
      },
      eventReceive: function(event) {
        alert(JSON.stringify(event, null, 4));
      }
    });
    

    0 讨论(0)
提交回复
热议问题