javascript - Fullcalendar: duplicate entry on dropping (external) -
i using while adding events fullcalendar external drag , drop, item doesn't id modify dropped element (title, id , date) , callback in drop function of fullcalendar
var url = "json-save-urlaub.php?event="+date.format()+"&allday="+date.hastime(); $.post( url, function(data){ //callback function retrieving response sent controller/action //event object rendered calendar var event = jquery.parsejson(data); //actually rendering new event calendar $('#calendar').fullcalendar('renderevent', event, true); //$('#calendar').fullcalendar('refetchevents'); $('#calendar').fullcalendar('unselect'); } );
however have 2 entries when drop element on fullcalendar since callback gives me new event object , 1 dropped can't remove since has no id , can't remove manually neither can use url call.
the line $(this).remove();
has no effect. neither has $("#calendar").fullcalendar( 'removeevents', copiedeventobject._id);
when copying dropped element first. how can have 1 element when dropping it?
according fullcalendar docs renderevent
"normally, event disappear once calendar refetches event sources (example: when prev/next clicked). however, specifying stick true cause event permanently fixed calendar."
when create object, need set within object data not stick. ie. stick: false
, or remove stick: true
$('#external-events .fc-event').each(function() { // store data calendar knows render event upon drop $(this).data('event', { title: $.trim($(this).text()), // use element's text event title stick: false // (see docs on renderevent method) }); // make event draggable using jquery ui $(this).draggable({ zindex: 999, revert: true, // cause event go revertduration: 0 // original position after drag }); });
Comments
Post a Comment