Instagram动态添加嵌入时嵌入不起作用 [英] Instagram embeds not working when adding embeds dynamically

查看:200
本文介绍了Instagram动态添加嵌入时嵌入不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在加载无限卷轴上的帖子的博客上工作。每篇博文都可能有也可能没有Instagram嵌入。我发现页面上显示的第一个将被处理(无论它是在初始页面标记中,还是动态添加),以下都不会。这是一个简单的JS Bin来说明问题:

Working on a blog that loads posts on an infinite scroller. Each blog post may or may not have Instagram embeds. I'm finding that the first one that shows on the page will get processed (regardless if it's in the initial page markup, or dynamically added), the following ones will not. Here is a simple JS Bin that illustrates the problem:

http://jsbin.com/hilixi/1/edit?html,js,output

第一个Instagram嵌入在初始页面标记中。在4秒后页面加载后添加另一个Instagram嵌入。第二个嵌入添加不会得到处理。

The first Instagram embed is in the initial page markup. Another Instagram embed is added after page load, after 4 seconds. The second embed add does not get processed.

任何想法为什么?看来Instagram嵌入脚本只运行一次。我可以用任何方式强制刷新吗?

Any ideas why? It seems the Instagram embed script will only run once. Any way I can force it to refresh?

谢谢,
马特

推荐答案

Instagram的嵌入代码附带的embed.js脚本有一个你可以调用的处理函数。

The embed.js script that comes with Instagram's embed code has a process function you can call.

window.instgrm.Embeds.process()

只要加载动态内容,就可以使用它。

Just use that whenever your dynamic content loads.

这篇关于Instagram动态添加嵌入时嵌入不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆