Categories

Wednesday, May 29, 2024
#919814419350 therichposts@gmail.com
FullCalendar

How to get events count on dayClick FullCalendar?

Get events count on dayClick FullCalendar

Hello to all, welcome to therichpost.com. In this post, I will tell you, How to get events count on dayClick FullCalendar? fullcalendar is the best A JavaScript event calendar. Customizable and open source. In this post, we will get events count on dayClick FullCalendar.

Here is the working and tested complete code for Get events count on dayClick FullCalendar and you can paste this code into your html file:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.css' rel='stylesheet' />
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/
bootstrap.min.css'>
<link href='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.print.min.css' rel='stylesheet' media='print' />
<script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/lib/moment.min.js'></script>
<script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/lib/jquery.min.js'></script>
<script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min
.js'></script>
<script>

  $(document).ready(function() {

    $('#calendar').fullCalendar({
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,basicWeek,basicDay'
      },
      defaultDate: '2018-03-12',
      navLinks: true, // can click day/week names to navigate views
      editable: true,
      eventLimit: true, // allow "more" link when too many events
      events: [
        {
          title: 'All Day Event',
          start: '2018-03-01',

        },
        {
          title: 'Long Event',
          start: '2018-03-07'
          
        },
        {
          id: 999,
          title: 'Repeating Event',
          start: '2018-03-09'
        },
        {
          id: 999,
          title: 'Repeating Event',
          start: '2018-03-16'
        },
        {
          title: 'Conference',
          start: '2018-03-11'
          
        },
        {
          title: 'Meeting',
          start: '2018-03-12'
          
        },
        {
          title: 'Lunch',
          start: '2018-03-12'
        },
        {
          title: 'Meeting',
          start: '2018-03-12'
        },
        {
          title: 'Happy Hour',
          start: '2018-03-12'
        },
        {
          title: 'Dinner',
          start: '2018-03-12'
        },
        {
          title: 'Birthday Party',
          start: '2018-03-13'
        },
        {
          title: 'Click for Google',
          url: 'http://google.com/',
          start: '2018-03-28'
        }
      ],
       dayClick: function(date, allDay, jsEvent, view) {
                  var eventsCount = 0;
                 var date = date.format('YYYY-MM-DD');

                  $('#calendar').fullCalendar('clientEvents', function(event) {
                    var start = moment(event.start).format("YYYY-MM-DD");
                    var end = moment(event.end).format("YYYY-MM-DD");
                    if(date == start)
                    {
                      eventsCount++;

                    }

                  });
                  alert(eventsCount);

        }
    });

  });

</script>
<style>

  body {
    margin: 40px 10px;
    padding: 0;
    font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
    font-size: 14px;
  }

  #calendar {
    max-width: 900px;
    margin: 0 auto;
  }

</style>
</head>
<body>

  <div id='calendar'></div>

</body>
</html>

 There are so many tricks in fullcalendar and I will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.