Callback for clicks on the button "month", "week", "day"?

I need to run some javascript code to reload the calendar when the user presses the day / week / month buttons. Is there any callback like dayButtonClicked () or something else?

BUG:

when I download the calendar first. The initial look looks great, mine initially loads the day. As soon as I upload another view, for example, a week. Each individual record is duplicated and shows both data sources. If I then go back again and move between day and month, the data will return to normal. It happens that removeEventSource is not called when it first loads a new view after clicking from day to week. have you seen this before?

<script type='text/javascript'> $(document).ready(function() { var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); var loadUrl = "menu_booking.php?ne=1&calsub=1"; var lastView; var fullSource = "../fullcalendar/json-events.php?idc=<?= $sClient ?>&v=long"; var liteSource = "../fullcalendar/json-events.php?idc=<?= $sClient ?>"; $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, columnFormat: { month: 'ddd', week: 'ddd d/M', day: 'dddd d/M' }, defaultView: 'agendaDay', firstDay: 1, //editable: true, selectable: true, allDaySlot: false, firstHour: 7, viewDisplay: function(view) { if (lastView == undefined) { lastView = 'firstRun'; } if (view.name != lastView ) { if (view.name == 'agendaWeek') { $('#calendar').fullCalendar( 'removeEventSource', fullSource ); $('#calendar').fullCalendar( 'removeEventSource', liteSource ); $('#calendar').fullCalendar( 'addEventSource', fullSource ); } if (view.name == 'agendaDay') { $('#calendar').fullCalendar( 'removeEventSource', fullSource ); $('#calendar').fullCalendar( 'removeEventSource', liteSource ); $('#calendar').fullCalendar( 'addEventSource', liteSource ); } if (view.name == 'month') { $('#calendar').fullCalendar( 'removeEventSource', fullSource ); $('#calendar').fullCalendar( 'removeEventSource', liteSource ); $('#calendar').fullCalendar( 'addEventSource', fullSource ); } lastView = view.name; } }, timeFormat: { // for event elements agendaDay: '', agendaWeek: '', month: '', '': 'h(:mm)t' // default }, }); //$('#calendar').limitEvents(2); }); </script> 

I even copied your code exactly how you do it, because I thought there was a problem with my code. even if I move on to this:

  //VIEW CHANGE - ALSO ADDS INITIAL SOURCES PER DAY VIEW viewDisplay: function(view) { $('#calendar').fullCalendar( 'removeEventSource', fullSource ); $('#calendar').fullCalendar( 'removeEventSource', liteSource ); $('#calendar').fullCalendar( 'addEventSource', fullSource ); } }, 

It still doubles the load when I switch from the default loaded view to another. I'm starting to think that this is definitely a mistake in FullCalendar. His driving me nuts

EDIT 2: MY GOD. I can't believe this finally works!

I have no idea why, but I had to swap addEventSource and removeEventSource now looks something like this:

  viewDisplay: function(view) { if (lastView == undefined) { lastView = 'firstRun'; } //alert("viewname: "+ view.name + "lastView: " + lastView); if (view.name != lastView ) { if (view.name == 'agendaWeek') { $('#calendar').fullCalendar( 'addEventSource', shortSource ); $('#calendar').fullCalendar( 'removeEventSource', longSource ); $('#calendar').fullCalendar( 'removeEventSource', shortSource ); } if (view.name == 'agendaDay') { //alert("in day: add litesource"); $('#calendar').fullCalendar( 'addEventSource', longSource ); $('#calendar').fullCalendar( 'removeEventSource', longSource ); $('#calendar').fullCalendar( 'removeEventSource', shortSource ); } if (view.name == 'month') { //alert("in month: Delete litesource"); $('#calendar').fullCalendar( 'addEventSource', shortSource ); $('#calendar').fullCalendar( 'removeEventSource', longSource ); $('#calendar').fullCalendar( 'removeEventSource', shortSource ); } lastView = view.name; } }, 
+8
javascript html javascript-events fullcalendar
source share
2 answers

Yes - unfortunately, depending on how you look at it - it can be either a feature or an error!?! The important line is

 ewDisplay: function(view) { if (lastView == undefined) { lastView = 'firstRun'; } if (view.name != lastView ){ ... 

From my other message!

Why lastView == undefined ? This is due to the fact that when the calendar is first loaded even before something appears on the screen, this event is triggered!

So, I do var = lastview to leave it undefined when the event fires on the first assignment of firstRun , it may be something really, but not the actual name of any monthView This step skips the first event - and will not add your channel twice! I added both of these things as a bug with the developers .. but they think about it because they are controversial features.

So, there is only solid coding of the skip method, and that is why for this whole lastview . I spent 2 or 3 days trying to debug this problem; you’ll need to keep track of your code line by line and see when feeds are added and somehow avoid it.

Remember to set the last viewname at the end of the event.

  ... lastView = view.name; } 
+2
source share

Usually clicking on the browse button triggers this event

Be careful because this event also fires if you change the days in the daytime or the monthly in the monthly view, but you skip this while keeping the last variable

JQuery ..

 . viewDisplay: function(view) { ** } . 

Change to

 .fullCalendar( 'refetchEvents' ) 

He will receive your feed again. as updating and updating any changes that may have occurred http://arshaw.com/fullcalendar/docs/event_data/refetchEvents/

or you can switch sources

 $('#calendar').fullCalendar( 'removeEventSource', '/diaryFeed.aspx?style=Complex' ); $('#calendar').fullCalendar( 'addEventSource', '/diaryFeed.aspx?style=Basic' ); 

But to find out which buttons were pressed, you will need to do this

  eventClick: function( event, jsEvent, view ) { } 
+1
source share

All Articles