Skip to content Skip to sidebar Skip to footer

Highlight Fullcalendar Events That Expands Over Multiple Rows/columns

In my Angular web app I'm using Angular UI Calendar combined with Fullcalendar to show user's events. In this when a user click on an event it gets highlighted, but this has a litt

Solution 1:

Fullcalendar 2.4 on hover demo (non-angular) https://jsfiddle.net/4kbLa4da/

$('#calendar').fullCalendar({
  defaultDate: '2016-03-01',
  events: [{
    start: '2016-03-01',
    end: '2016-03-05',
    title: 'Event 1'
  }, {
    start: '2016-03-06',
    end: '2016-03-15',
    title: 'Event 2',
    id: 3
  }],
  eventRender: function(event, element, view) {
    // event._id gets auto-populated, either event.id or auto-generated value
    element.attr('data-id', event._id);
    toggleClass(event._id);
  },
  eventMouseover: function(event, jsEvent, view) {
    toggleClass(event._id);
  },
  eventMouseout: function(event, jsEvent, view) {
    toggleClass(event._id);
  }
});

functiontoggleClass(id) {
  /* Find all segments for the specific event and toggle a class */var $event = $('a.fc-event[data-id="' + id + '"]');
  $.each($event, function() {
    $(this).toggleClass('my-highlight');
  });
}

If you want it on event click: https://jsfiddle.net/4kbLa4da/2/

eventClick: function (event, jsEvent, view) {
    toggleClass(event._id);
  }
 /* ... *//* And change toggleClass to turn it off first */functiontoggleClass(id) {
  /* Find all segments for the specific event and toggle a class */var $event = $('a.fc-event[data-id="' + id + '"]');
  $('a.my-highlight').each(function () {
    $(this).toggleClass('my-highlight');
  });
  $.each($event, function() {
    $(this).toggleClass('my-highlight');
  });
}

Solution 2:

Post a Comment for "Highlight Fullcalendar Events That Expands Over Multiple Rows/columns"