jquery - Fullcalender - multiple calls are made when clicked on prev and next button -
when clicked on nextor previous button makes multiple calls , many time click on these buttons many time cal made . below code
var sourcefullview = "@url.action("getdiaryevents","leavecalender")"; var sourcesummaryview="@url.action("getdiarysummary","leavecalender")"; var calloading = true;$('#calendar').fullcalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,basicweek,basicday' }, defaultview: 'month', events:"@url.action("getdiaryevents","leavecalender")", viewrender: function (view, element) { if (!calloading) { if (view.name == 'month') { $('#calendar').fullcalendar('removeevents'); $('#calendar').fullcalendar('removeeventsource', sourcefullview); $('#calendar').fullcalendar('addeventsource', sourcesummaryview); } else { $('#calendar').fullcalendar('removeevents'); $('#calendar').fullcalendar('removeeventsource', sourcesummaryview); $('#calendar').fullcalendar('addeventsource', sourcefullview); } } } }); calloading = false; });
please help me find solution
from documentation, viewrender:
this callback triggered when user changes view, or when of date navigation methods called.
so removing , adding events in every alter of view, including clicking prev/next buttons.
usually, sources add together 1 time @ beginning, when init calendar.
$('#calendar').fullcalendar({ eventsources: [ sourcefullview, sourcesummaryview ] });
jquery fullcalendar
No comments:
Post a Comment