Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: fullcalendar.js

  • Thread Tools
  • Rate This Thread
  1. #1
    New to the CF scene
    Join Date
    Apr 2016
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    fullcalendar.js

    Hi guys,
    I am using the fullcalendar jquery plugin, but want it to refresh when a user selects a value from a dropdown list.
    i have tried the following but it doesn't refresh the calendar.
    Code:
    $('#employees').change(function(){
    //alert($('#employees').val());
    var userid=$('#employees').val();
    		 $.ajax({
    			url: 'process.php',
    	        type: 'POST', // Send post data
    	        data: 'type=fetch&userid='+userid,
    	        async: false,
    	        success: function(s){
    	        	freshevents = s;
    	        }
    		});
    		$('#calendar').fullCalendar('addEventSource', JSON.parse(freshevents));
    });
    any ideas
    thanks
    Jamie

  2. #2
    Regular Coder
    Join Date
    Feb 2016
    Posts
    128
    Thanks
    0
    Thanked 32 Times in 32 Posts
    Ajax works asynchronously: When this
    Code:
    $('#calendar').fullCalendar('addEventSource', JSON.parse(freshevents));
    is executed, the variable freshevents is not yet set. You have to move this insctruction to the success callback:
    Code:
    $('#employees').change(function(){
    //alert($('#employees').val());
    var userid=$('#employees').val();
    		 $.ajax({
    			url: 'process.php',
    	        type: 'POST', // Send post data
    	        data: 'type=fetch&userid='+userid,
    	        async: false,
    	        success: function(s){
                            $('#calendar').fullCalendar('addEventSource', JSON.parse(s));
    	        }
    		});
    });
    Edit: Sorry, I didn't notice that you set async to false. Anyway I would recommend doing without this and place the instruction inside the success callback.
    Last edited by Sempervivum; 05-15-2016 at 10:06 PM.

  3. #3
    New Coder
    Join Date
    May 2016
    Location
    USA
    Posts
    20
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Have you thought about using a setInterval call. This way you could have the calendar refresh every (whatever you set the time for) and it takes almost no resources and would constantly refresh for all users that are connected to the site.

    It would not require any inputs from a user to refresh!

    A lot of that would be determined as to what you are using the calendar for on the site. It may be nice if it refreshed for everyone that was seeing it.

    Just a thought.

    Mike


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •