JuanArreguin
JuanArreguin

Reputation: 3

Fullcalendar: on 'dayClick' pop-up IF an event exists

The way I'm trying to make this work is the idea of "blocking a day" to unavailable and available. How can I make the whole day's block clickable even if there is an event on it?

If there currently is an event on a day I want to block, I'd like to see that event in a pop-up.

One of the issues is that currently only way to activate "dayClick" is if you click on an empty area. But if you click on an event it will not trigger "dayClick". Any help is greatly appreciated!

Upvotes: 0

Views: 3549

Answers (1)

ShadeTreeDeveloper
ShadeTreeDeveloper

Reputation: 1581

The data that dayClick needs is not available when you click on an event (eventClick). I don't know of a way to drill through the event to get to dayClick. i.e., I can't think of a way to call $.trigger to call dayClick.

You should be able to do what you need in the eventClick callback. When creating individual events, set a property to available or unavailable. Maybe something like this:

var events = [{
                 id: 1,
                 title: 'This is a blocked day',
                 start: 'Wed, 18 Oct 2009 08:00:00 EST',
                 color:'#fff',// red
                 blocked: true
             },
             {
                 id: 2,
                 title: 'This is an available day',
                 start: 'Thu, 19 Oct 2009 08:00:00 EST',
                 color: '#07A800', // green
                 blocked: false
             }];

$('#cal').fullcalendar({
    events: events,
    eventClick: function(calEvent, jsEvent, view) {
        if(calEvent.blocked == true) {// be sure to set a 'blocked' property in your event
            alert('This time is not available!');                
        } else {
            $('#newEventDialog').dialog('open');// open a dialog to save new event
        }
    }
});

Upvotes: 2

Related Questions