jQuery附加Instagram的blockquote动态嵌入无法正常工作 [英] jQuery appending Instagram's blockquote embedding dynamically doesn't work

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

问题描述

我有一个jQuery脚本,用于附加Instagram块引用,但不适用于第二个附加.第一次添加时,blockquote会像应有的那样转换为iframe,但是如果我再次尝试,它只会停留在blockquote上.

I have a jQuery script that appends the Instagram blockquote, but it doesn't work on the second append. The first time it gets appended, the blockquote converts to the iframe like it should, but if I try it again, it just stays a blockquote.

function appendInstagram($controls){
  var instagramURL = $('#js-instagram-url-edit').val();
  var instagramScript = '<script async defer src="//platform.instagram.com/en_US/embeds.js"><\/script>'
  var instagramHtml = $('<blockquote class="instagram-media" 
                         data-instgrm-captioned data-instgrm-version="7">
                           <div style="padding:8px;"> 
                             <a href="'+instagramURL+'" target="_blank"></a>
                           </div>
                         </blockquote>' + instagramScript);
  updateContent(instagramHtml, $controls);
}

这个想法是当执行此函数时,块引用通过updateContent()

The idea is when this function gets excecuted, the blockquote gets appended through updateContent()

推荐答案

我发现instagram具有此功能

i found out that instagram has this

window.instgrm.Embeds.process()

每次都需要执行.

这篇关于jQuery附加Instagram的blockquote动态嵌入无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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