Add font awesome icon to full calendar title

后端 未结 6 1148
不思量自难忘°
不思量自难忘° 2020-12-15 23:41

I\'m using wordpress, formidable forms and full calendar to create a bespoke calendar solution

I have everything working except for I\'d like to add a font awesome i

6条回答
  •  失恋的感觉
    2020-12-15 23:52

    With fullcalendar V4 my render looks like this

    json title with $ICON as placeholder:

    {
      start: date
      title: '$ICON custom_name'
      img: 'fontawesome-icon-name'
    }
    
    eventRender: function(info) {
      info.el.innerHTML = info.el.innerHTML.replace('$ICON', "");
    }
    

    Edit: With fullcalendar 5.x.x, my approach is a little bit different and as I only add the icon at the front I don't need the $ICON placeholder anymore.

    eventContent: function (args, createElement) {
      const icon = args.event._def.extendedProps.img;
      const text = " " + args.event._def.title;
      return {
        html: text
      };
    },
    

    Cheers Hannes

提交回复
热议问题