How to add close button to the event block in Fullcalendar

半城伤御伤魂 提交于 2020-01-04 23:06:29

问题


I need to add 'close' button to the event which would remove it from the calendar. As 'text' field doesn't accept HTML, I can't do this directly. What is the best way to modify event HTML ?


回答1:


Adding a trash icon from Bootstrap-3

eventRender: function(event, element) {
   element.html(event.title + '<span class="removeEvent glyphicon glyphicon-trash pull-right" id="Delete"></span>');
}

The event can be captured in the "eventClick":

eventClick: function(calEvent, jsEvent, view) {
  if (jsEvent.target.id === 'Delete') {
    $("#myModal").modal(); // Maybe show a modal dialog asking the user if he wants to delete the event. 
  }
}



回答2:


I succeeded to add a close button with the eventRender callback function.

 eventRender: function(event, element) {
                    element.html(event.title+"<i  class='fa fa-close pull-right text-danger' id='"+event.id+"'></i>");
                },

But i could not get the button to work. Please let me know if you could get the button to work.



来源:https://stackoverflow.com/questions/22240871/how-to-add-close-button-to-the-event-block-in-fullcalendar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!