question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Easy way to get HTML into an event title

See original GitHub issue

Hi there, I’m using fullcalendar (nice work~) and find what it seem to be a missing function. When you put html in the event title, it’ll always be html-escaped, I understand it’s the best default way, as some title may contain some html char and user input that should be bulletproof .

But why you don’t have put an (bool) textEscape {default : TRUE} option in Event Source Object ? (and in Event Object to as it’s the same)

I’m a big boy, I’m able to deal with htmlEscape by myself and I think I’m not the only one here… (i’ve found many issue about html in title on google) But having to use an ugly hook with eventRender just to put a span for a glyphicons seem to be a bit overkill for me…

Tanks, Blag

TL;DR :

  • adding option (bool) textEscape {default : TRUE} on Event Source Object and Event Object
  • dealing with this kind of data :
{
    "events": [
        {
            "title": "<b>Event in bold</b> 1",
            "start": "2011-04-04"
        },
        {
            "title": "<span class=""glyphicons""></span> Event with glyphicons",
            "start": "2011-05-05"
        }
        // etc...
    ],
    "textEscape": false,   // new option to disable the auto escape
    "color": "yellow",   // an option!
    "textColor": "black" // an option!
}

or

{
    "events": [
        {
        "title": ">> Event  escaped",
        "start": "2011-04-04"
        },
        {
            "title": "<span class=""glyphicons""></span> Event with HTML !",
            "start": "2011-05-05",
            "textEscape": false   // new option to disable the auto escape
        }
        // etc...
        ],
    "color": "yellow",   // an option!
    "textColor": "black" // an option!
}

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:33
  • Comments:38 (5 by maintainers)

github_iconTop GitHub Comments

52reactions
tyrann0uscommented, Apr 27, 2018

If you already got HTML in the title you could do something like this:

eventRender: function( event, element, view ) {
 	var title = element.find( '.fc-title' );
	title.html( title.text() );
}
35reactions
danhnguyeencommented, May 16, 2016
eventRender: function( event, element, view ) {
       element.find('.fc-title').prepend('<span class="glyphicon"></span> '); 
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I insert HTML into an event title in fullCalendar 4?
In your eventRender, look for the selector of the title and change the innerHtml: eventRender: function(info) { ... let selector = info.el.
Read more >
HTML title tag - W3Schools
Go for a longer, descriptive title (avoid one- or two-word titles); Search engines will display about 50-60 characters of the title, so try...
Read more >
How to get the title of an HTML page ? - GeeksforGeeks
Example 2: This example gets the title of document by first selecting the title by tag name and then taking the element at...
Read more >
title - HTML: HyperText Markup Language - MDN Web Docs
Use the title attribute on an iframe to clearly identify the content of the iframe to screen readers. Open main menu. Home ·...
Read more >
Topic Tag: Event Title - WordPress.org
Topic Tag: Event Title · [Simple Calendar - Google Calendar Plugin] event-title in Full calendar grid only showing one line. Started by: evonne01...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found