Reputation: 891
I have a fullCalendar in which I dynamically add a remove icon on the events. You can watch the jsFiddle.
In the fiddle you can see that on the top of the page, there is a remove icon which was added dynamically. Clicking on it will trigger a message in the console.
However, when I add the same code to the fullCalendar events (in the eventRender
function), the same handler is added but is not triggered when you click on the icon.
Any idea why this won't work?
Upvotes: 3
Views: 1400
Reputation:
The issue is a click event on dynamically created elements. If you change the click function to:
$(document).on("click", ".fc-event-delete-button", function(event) {
console.log("click", event);
})
That will fix the problem.
With dynamically created elements you need to write a click function like that. Attaching it to something already present on the page and specifying the exact element within the brackets.
Here's an updated JS Fiddle example
Upvotes: 4