jquery - dragging and dropping date not working right in fullcalendar -
i using jquery fullcalendar application. trying validate can not drag , drop event past date.here code,
$(document).ready(function() { var dragfingdate; $('#calendar').fullcalendar({ //defaultdate: '2015-02-12', editable: true, eventlimit: true, // allow "more" link when many events events: [ here events ], eventdrop : function(event,revertfunc) { //var moment = $('#calendar').fullcalendar('getdate'); //alert("the current date of calendar " + moment.format("yyyy-mm-dd")); var dropeddate = event.start.format("yyyy-mm-dd"); alert(dropeddate); var todaydate = $('#calendar').fullcalendar('getdate'); var today_newformatdate = todaydate.format("yyyy-mm-dd"); alert(today_newformatdate); if(dropeddate < today_newformatdate) { alert("can not move previous dates."); revertfunc(); //$('#calendar').fullcalendar('selectable', false); } else { //alert("can move next dates."); var r = confirm("are sure want shift?"); if(r == true) { // here ajax code updte db //alert("droped "+event.title +"on date of "+event.start.format("yyyy-mm-dd")); } else { revertfunc(); } } } });
but code not working fine.when drag , drop first time, example 2015-04-27 2015-04-20 shows alert "can not move previous dates." if again drag , drop same date date means dropped date different dropped date(example if drag , droped 2015-04-28 2015-04-15 dropped date shows 2015-04-20,15 or other date).
update : found problem when called revertfunc there showing selectable wherever cursor moving on date.when click on calendar selectable hold date , assigned dragged date.
why happen , how fix?
the problem eventdrop
function try replacing function :
eventdrop: function( event, delta, revertfunc, jsevent, ui, view ) { // add logic here }
note: revertfunc
third
parameter eventdrop
function check docs here.
the best solution though suggest is, make simple change in array passing calendar i.e editable: false
, below code.
$('#calendar').fullcalendar({ events: [ { title : 'event1', start : '2010-01-09t12:30:00', end : '2010-01-09t12:40:00', editable: false //set true if want make editable } ] });
note: in above case have manipulate event array passing calendar beforehand.
Comments
Post a Comment