It seems that the scripts that are responsible for rendering the Instagram and Twitter blockquotes are running only once.
When navigating to another page containing Twitter or Instagram blockquotes the embedded iframe is viewed correctly, but when navigating to the same page, the blockquotes are NOT rendered!
This is how I had included the corresponding scripts:
twitterPosts = function (d, s, id) {
let js: any,
fjs = d.getElementsByTagName(s)[0],
p = 'https';
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = p + "://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "twitter-wjs");
instagramPosts = function (d, s, id) {
let js: any;
let fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.setAttribute("onLoad", "window.instgrm.Embeds.process()");
js.id = id;
js.src = "https://platform.instagram.com/en_US/embeds.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "instagram-wjs");
ionViewWillEnter() {
...
this.instagramPosts;
this.twitterPosts;
...
}
ionViewWillLeave() {
this.removeScript();
}
removeScript() {
let fjs = document.getElementsByTagName('script')[0];
fjs.parentElement.removeChild(document.getElementById('instagram-wjs'));
}
I also had tried to run these scripts after adding the HTML content containing the blockquotes:
this.htmlContent = this.domSanitizer.bypassSecurityTrustHtml(this.post.content);
this.instagramPosts;
this.twitterPosts;
How can I lmake the scripts always render the blockquotes?!