| Issue 2398: | htmlEscape function on event.title in fullcalendar.js line 5949 version 2.2.3 | |
| 1 person starred this issue and may be notified of changes. | Back to list |
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
Status:
Done
Jan 6, 2015
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?
Jan 6, 2015
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/
|
|
| ► Sign in to add a comment |