Issue 2398: htmlEscape function on event.title in fullcalendar.js line 5949 version 2.2.3
Status:  Done
Owner: ----
Closed:  Jan 2015
Reported by charles....@trinityis.com, Dec 26, 2014
There is a function in the fullcalendar.js file that among other items escapes HTML on the event.title.  

I think that it would be helpful if there was a way to inject HTML into the title and other text elements of the calendar.

If this cannot be done, can you explain why the htmlEscape function was used.

Jan 6, 2015
Project Member #1 adamrs...@gmail.com
Inject your HTML into the event's elements with the `eventRender` hook:
http://fullcalendar.io/docs/event_rendering/eventRender/
Status: Done
Jan 6, 2015
#2 charles....@trinityis.com
I was using the eventRender function, however it reverts back to raw HTML while moving or resizing.  See screenshot.  Also, when the calendar is loading there is a blip of un-rendered HTML.  See second screenshot.

To correct this I changed the following lines of code in the fullcalendar.js file.

In the fgSegHtml function around line 5949
(htmlEscape(event.title || '') || ' ') + // we always want one line of height 
- to - 
(event.title || ' ') +

and 

fgSegHtml function around line 7114
htmlEscape(event.title) 
- to -
event.title

Why is the htmlEscape function needed in these two areas?


				
Screenshot 2015-01-06 12.54.21.png
53.5 KB   View   Download
Screenshot 2015-01-06 12.58.11.png
60.8 KB   View   Download
Jan 6, 2015
Project Member #3 adamrs...@gmail.com
The htmlEscape function is important because it allows the event.title field to contain special HTML characters, like "<" or "&", but have them displayed correctly. So, events like "My <cool> event" will display as-is.

It also prevents the developer from shooting themselves in the foot and providing mangled HTML that will destroy the rendering of all elements afterwards, leaving them confused with no indication of what went wrong.

It also keeps the event data's semantic meaning separate from its rendering logic. This is a trend nowadays with templating languages like Mustache and others.

I'm not sure why you are experience this problems you just described. Are you sure you're not using eventAfterRender instead?

Try not to use the `title` field to store HTML. Instead, use another field, like `titleHtml`.


	example event object:

		{
			titleHtml: 'my <b>cool</b> event title'
		}

	example eventRender:

		eventRender: function(event, el) {
			el.find('.fc-title').html(event.titleHtml);
		}

I cannot help you further with this problem. If you feel there is a legitimately bug with `eventRender`, please post a new ticket linking to an online demo of the problem:
http://fullcalendar.io/wiki/Reporting-Bugs/