0

I want to set a different colour for events that are in the past (so yesterday and back) and then have a different colour for future dates(today and dates in the future) i have code below however this does not work for future dates

events: {
            url: 'load_Emp_Roster.php',
            error: function() {
                $('#script-warning').show();
            },
            success: function(data){
                for(var i=0; i<data.length; i++){//The background color for past events
                    if(moment(data[i].start).isBefore(moment())){//If event time is in the past change the general event background & border color
                        data[i]["backgroundColor"]="#f44336";
                        data[i]["borderColor"]="#336600";
                    }
                    else{
                        data[i]["backgroundColor"]="#4CAF50";
                        data[i]["borderColor"]="#336600";
                    }
                }
            }
        },
brombeer
  • 8,716
  • 5
  • 21
  • 27
  • Please explain 'this does not work for future dates'; what styling is applied for future dates? – Rob_M Mar 07 '19 at 11:46
  • the else does not work , i want it to display a different colour for future events but it no longer displays future events – Katie O Donovan Mar 07 '19 at 11:49
  • You might find this approach helpful, using the `dayRender` callback to style days: https://stackoverflow.com/a/17930817/1212228 – Rob_M Mar 07 '19 at 11:50
  • 1
    @Rob_M OP is trying to style individual events, not days – ADyson Mar 07 '19 at 12:05
  • "it no longer displays future events" ...have you verified (using the DOM inspector in your browser or the JS debugger) whether it does in fact change the colour properties of the future events? Have you potentially set the colours to the same as the background of the calendar or something? That might explain why you can't see them. Again the DOM inspector will tell you whether the event HTML is actually there or not. P.S. if you're like us to test this for you, please provide a sample of the JSON which comes back from load_emp_roster.php. Thanks. – ADyson Mar 07 '19 at 12:08

0 Answers0