javascript - Fullcalender next and previous make more function call in MVC4 -
i have tried code fullcalender.js , moment(), in jquery..but getting function call on single click next , previous button ... plz one
$(document).ready(function () { var calloading = true; $('#calendar').fullcalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaweek,agendaday' }, defaultview: 'month', defaultdate:moment(), editable: true, alldayslot: false, selectable: true, slotminutes: 15, events: function (start, end, callback) { $.getjson("@url.action("eventsummary")", function (locationsarray) { var result = $(locationsarray).map(function () { return { title: this.title, start: this.start, end: this.end, allday: this.editable }; }).toarray(); callback(result); }); }, eventclick: function (calevent, jsevent, view) { alert('you clicked on event id: ' + calevent.id + "\nspecial id: " + calevent.somekey + "\nand title is: " + calevent.title); }, eventdrop: function (event, daydelta, minutedelta, allday, revertfunc) { if (confirm("confirm move?")) { updateevent(event.id, event.start); } else { revertfunc(); } }, eventresize: function (event, daydelta, minutedelta, revertfunc) { if (confirm("confirm change appointment length?")) { updateevent(event.id, event.start, event.end); } else { revertfunc(); } }, dayclick: function (date, allday, jsevent, view) { $('#eventtitle').val(""); $('#eventdate').val(moment(date).format('dd/mm/yyyy')); $('#eventtime').val(moment(date).format('hh:mm')); showeventpopup(date); }, viewrender: function (view, element) { if (!calloading) { if (view.name == 'month') { $('#calendar').fullcalendar('removeeventsource', sourcefullview); $('#calendar').fullcalendar('removeevents'); $('#calendar').fullcalendar('addeventsource', sourcesummaryview); } else { $('#calendar').fullcalendar('removeeventsource', sourcesummaryview); $('#calendar').fullcalendar('removeevents'); $('#calendar').fullcalendar('addeventsource', sourcefullview); } } } }); calloading = false; });
it function call prev, increments call twice each click
hai @saneesh try one....
events: function (start, end, timezone, callback) { $.ajax({ url : '@url.action("getevents","fullcalender")', datatype: "json", data: { start: start.unix(), end: end.unix() }, success: function (doc) { var events = []; $.each(doc, function (i, item) { //alert(item["title"]); events.push({ title: $(this).attr('title'), start: $(this).attr('start'), // parsed end: $(this).attr('end') }); }); callback(events); } }); }
Comments
Post a Comment