Skip to content
Advertisement

Why MutationObserver does not work for title change in FullCalendar?

I need to know the current title of a FullCalendar. The title could be changed after clicking the navigation buttons.

enter image description here

I did not find any FullCalendar native way how to get the title so I was looking for other ways to find out. I thought that MutationObserver would work.. But it does not work when changing the text through the buttons. If the change is done via JavaScript

JavaScript

then the MutationObserver works.

Any idea how to fix that? Working jsFiddle

Advertisement

Answer

I was able to observe the changes resulting from clicks on the month increment/decrement buttons by adding subtree: true to the config.

From MDN’s page on “MutationObserver.characterData”:

Note that this doesn’t monitor content of an HTMLElement, even if it only contains text inside, as it only monitors text nodes themselves. So either pass directly a text node to the observe() method or you need to also set subtree: true.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement