Title: [Plugin: Events Manager] Calendar Function &#8211; AJAX function or Classes help
Last modified: August 20, 2016

---

# [Plugin: Events Manager] Calendar Function – AJAX function or Classes help

 *  [Mr Brainz](https://wordpress.org/support/users/mr-brainz/)
 * (@mr-brainz)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/event-manager-calendar-function-ajax-function-or-classes-help/)
 * How you doing?
 * I’m using the beautiful Events Manager plugin to display a calendar of upcoming
   events. I want to be able to highlight each category with a different colour 
   on the calendar.
 * I tried to add categories as a class in the template but EM only outputs them
   as an unordered list.
 * My workaround was to populate a hidden DIV with the categories and use jQuery
   to generate classes off the back of that.
 * Template:
 * `<li><a href="#_EVENTURL"><span>#_24HSTARTTIME</span> <strong>#_NAME</strong>
   </a> <div class="eventcats">#_EVENTCATEGORIES</div></li>`
 * jQuery:
 *     ```
       if ( $j('.em-calendar-wrapper').length ) {
       	$j('.eventful > ul li, .eventful-today > ul li').each( function() {
       		var cats = '';
       		$j(this).find('.eventcats ul li').each( function() {
       			catit = $j(this).find('a').text();
       			cats = cats + catit.toLowerCase().replace(/ /g, '-') + ' ';
       		});
       		cats = $j.trim(cats);
       		$j(this).addClass(cats);
       	});
       }
       ```
   
 * This works, but the problem is that when you change month then the calendar updates
   with AJAX, and as the above jQuery is running on (document).load then it resets
   when the month is changed.
 * So my question is: Can I pass my function into the AJAX on change somewhere, 
   or better still, is there a way to add clean classes based on categories into
   the calendar item template?
 * I know you guys that run EM love taking on board suggestions so I thought I’d
   post here and try my luck.
 * Hope someone can help.
 * Greg

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [Mr Brainz](https://wordpress.org/support/users/mr-brainz/)
 * (@mr-brainz)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/event-manager-calendar-function-ajax-function-or-classes-help/#post-2504738)
 * Ok I’ve managed to hack my function into the events-manager.js file and it works,
   but this is obviously very bad practice as it will break when the plugin updates.
 * So any suggestions on another way to do this would be awesome like awesome sauce.
 * Thanks,
 * Greg
 *  [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/event-manager-calendar-function-ajax-function-or-classes-help/#post-2504920)
 * actually, an event is triggered –
 * $(this).trigger(’em_calendar_load’)
 * you can just bind to that in jquery
 *  Thread Starter [Mr Brainz](https://wordpress.org/support/users/mr-brainz/)
 * (@mr-brainz)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/event-manager-calendar-function-ajax-function-or-classes-help/#post-2505049)
 * Thanks so much for your help Marcus. I’d never binded a function to an event 
   before so I had to do some Googling.
 * Came up with
 * `$j(document).bind('em_calendar_load', function() { calColours(); });`
 * Worked like a charm.
 * Still think that there’s room for a way to add classes for even categories though.
   It will help with styling and therefore usability.
 * Cheers

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: Events Manager] Calendar Function – AJAX function or Classes
help’ is closed to new replies.

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [calendar](https://wordpress.org/support/topic-tag/calendar/)
 * [event](https://wordpress.org/support/topic-tag/event/)
 * [event-manager](https://wordpress.org/support/topic-tag/event-manager/)
 * [events](https://wordpress.org/support/topic-tag/events/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)

 * 3 replies
 * 2 participants
 * Last reply from: [Mr Brainz](https://wordpress.org/support/users/mr-brainz/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/event-manager-calendar-function-ajax-function-or-classes-help/#post-2505049)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
