Ghugu Ghugu - 3 days ago 4
Javascript Question

how to get the month and year which is displaying on the calendar

In fullcalendar.js I used this but in this i have given the static value.
How we can send the month and year which is displayed on the calendar inside the moment(""). So that its works fine using this it only display sep 2016 whenever i change month then refresh its rdirecting me to this page

<script>

$(document).ready(function() {

$('#calendar').fullCalendar({
height: 350,
contentHeight: 300,
aspectRatio: 2,
eventLimit: 6,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listMonth'
},
defaultDate: '<?=date("Y-m-d")?>',
navLinks: false, // can click day/week names to navigate views
businessHours: false, // display business hours
editable: false,
eventLimit: true,
events: [
{
title: '',
start: '',

color: '#ff5c29',
allDay : true,
eventColor: '#000'

},

<?php }?>
<?php foreach($records as $record){ ?>
{
title: '',
start: '',
overlap: false,

color: '',



],

});
var previousDate = moment("2016-09");
$('#calendar').fullCalendar('gotoDate', previousDate);
});
</script>


please help.

Answer
/* First Link */
        $('.fc-prev-button').click(function () {
                        var action = "prevMonth";
                        var view = $('#calendar').fullCalendar('getView');
                        var strView = view.name;
                        var prevMonthDate = view.start;
                        //alert(prevMonthDate);
                        var d = new Date(prevMonthDate);

                        var str1 = $.datepicker.formatDate('yy-mm', d);
                       //                        alert(str);
                        var MonthType = 'PrevMonth';

                        load(shiftdate, MonthType);

                    });

        /* Next Link */
        $('.fc-next-button').click(function () {
                        debugger;
                        var action = "nextMonth";
                        var view = $('#calendar').fullCalendar('getView');
                        var strView = view.name;
                        var nextMonthDate = view.start;
                        // alert(nextMonthDate);
                        var d = new Date(nextMonthDate);

                        var str2 = $.datepicker.formatDate('yy-mm', d);

                        var MonthType = 'NextMonth';
                        // alert(str);
                        load(shiftdate, MonthType);

                    });

    USING above code you  can get the month and year  display on the calender
Comments