Getting id from eventReceive

给你一囗甜甜゛ 提交于 2019-11-29 16:41:32

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

<div class='fc-event' data-event='{"id": 1, "randomProperty": "foobar", "title": "This is event 1"}'>My Event 1</div>

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

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

HTML

<div id='wrap'>

  <div id='external-events'>
    <h4>Draggable Events</h4>
    <div class='fc-event' data-event='{"id": 1, "randomProperty": "foobar", "title": "This is event 1"}'>My Event 1</div>
  </div>

  <div id='calendar'></div>

  <div style='clear:both'></div>

</div>

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));
  }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!