Skip to main content
Solved

Embeddable widget content with SPA

  • January 26, 2022
  • 3 replies
  • 65 views

We use the embeddable widget on our Docusaurus 2 documentation website.

However, the content of the widget does not change when navigating to other topics, probably because it is a single-page application (SPA).

Is there a way to make the widget reload the content after the page title has changed?

Best answer by SmartlyGreg

@JasperK as long as you can pinpoint when the widget needs to reload then you should be able to trigger it with javascript.

You can find all the info you need here:

I think the one you are after is: inSided.conversational.reload() 

3 replies

SmartlyGreg
Forum|alt.badge.img
  • Helper ⭐️⭐️⭐️
  • Answer
  • January 26, 2022

@JasperK as long as you can pinpoint when the widget needs to reload then you should be able to trigger it with javascript.

You can find all the info you need here:

I think the one you are after is: inSided.conversational.reload() 


  • Author
  • Contributor ⭐️⭐️
  • January 26, 2022

Thanks for the tip!

I managed to reload the widget content after a document title change using a MutationObserver:

// Create an observer instance
var observer = new MutationObserver(function (mutations) {
// Reload inSided widget
inSided.conversational.reload()
});

// Start receiving notifications
observer.observe(
document.querySelector('title'),
{ characterData: true, childList: true }
);

 


SmartlyGreg
Forum|alt.badge.img
  • Helper ⭐️⭐️⭐️
  • January 26, 2022

@JasperK great nice job!