CiE
CiE

Reputation: 33

fullcalendar viewRender Not working for me

Hi guys i'm using arshaw fullcalendar its a great plugin and i would like to get notified when the view changes in order to add a class to a span. i tried

    $('#calendar').fullCalendar({
        viewRender: function(view,element){alert("aha");},
            defaultView:'basicDay',
            theme: true,
            header:{ 
                    right: 'month basicWeek basicDay',
                    left: 'prev,next today',
                    center: 'title'

            },
            loading: function(bool){
                    if(bool){
                    $("body").addClass("loading"); 
            }else{
                    $("body").removeClass("loading");
                    }
            },
            lazyFetching: true,
            minTime: 8,
            maxTime: 17,
            allDaySlot: false,
            eventSources:[

            {
                    url: '/apptCalendar/appt?q=1',
                    color: '#FAF29B',
                    textColor: 'black',
                    allDayDefault: false
            },
            {
                    url: '/apptCalendar/appt?q=2',
                    color: '#4e394d1',
                    textColor: '#FAF29B',
                    allDayDefault: false
            },
                            {
                    url: '/apptCalendar/appt?q=3',
                    color: '#38df64',
                    textColor: 'black',
                    allDayDefault: false
            }


    ],
    eventRender: function(event, element){
        element.find('span.fc-event-title').html(element.find('span.fc-event-title').text());
            element.qtip({
                    content: {text:"<script>$('.qtip .addTitleInfo').addClass('hidden'); $(document).ready(function(){ $('#eventApptID"+event.id+"').each(function(){  $('#eventApptID"+event.id+"').val('"+event.appStatusID+"'); });  });</script><div><h6>Therapy Type: "+event.therapyType+"</h6></div><a href='/eval/new-eval/"+event.pat_id+"?appID="+event.thirdPAppID+"'"+"><i class='icon-plus-sign'></i> New Eval</a><br>\
                    <a href='/note/new-note/"+event.pat_id+"?appID="+event.thirdPAppID+"'"+"><i class='icon-plus-sign'></i> New Note</a>\
                    <div>DOB: "+event.dob+"</div><div>SSN: "+event.l4SSN+"</div><div>Appointment Status:</div><select id='eventApptID"+event.id+"' class='input-large' onChange='updateApptStatus(this.value,"+event.id+","+event.pat_id+")'>"+items+"</select><div>Comments: "+event.description+"</div>",
                    title: {text: event.title},
                    button: 'Close'},
                    show: {
                            solo: true
                    },
                    style: {
                            classes: 'qtip-bootstrap',
                            width: 300,
                            height: 300
                    },
                    hide: {
                            event: 'unfocus',
                    },
                    position:{
                            my: 'bottom center',
                            at: 'top center',
                            target: 'event',
                            viewport: $('#calendar')
                    }
            });
    }

});

and that did not prompt an alert when the view changed. i would like it to. Can anyone help me out?

Currently i have tried other methods of notification but have not been able to get it to work. Please let me know what i need to do to get this done.

Upvotes: 2

Views: 15021

Answers (1)

fijas
fijas

Reputation: 1274

The problem seems to be with your version of the fullcalendar library. This particular issue got me spinning for a while :(. The one you included in your fiddle was v1.6.2. I couldn't get it to successfully trigger the 'viewRender' callback too with that version. I checked the same code with v1.6.3 and that triggered the event. On doing a diff of the two versions, I found the following code block (which seems to be extremely relevant to the problem) missing in v1.6.2:

trigger('viewRender', currentView, currentView, currentView.element);

within the _renderView() function. Also to be noted is that v1.6.3 depends on jQuery v1.10.2 (although i'm not sure if it will not work with lower versions) so if you are not tied down to a specific version of jQuery, simply include the latest fullcalendar and you should be good to go...

Upvotes: 6

Related Questions