使Facebook插件响应 [英] Make Facebook plugin responsive

查看:64
本文介绍了使Facebook插件响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在使用新的Facebook插件(页面插件)并且很难在窗口调整大小时对其进行响应。



我已经设置了选项数据 - adapt-container-width =true,但只有当我有一个页面加载/重新加载时才触发。



请选择我的JSFiddle: http://jsfiddle.net/29zgc790/ (在exporer中尝试它,如果那不行,请尝试我的plunker: http://plnkr.co/edit/IPnjpJUXxkO4WTLFTTW0?p=preview )我已将插件的起始宽度设置为max(500px),但我希望在容器(窗口)变得比那个特定时间的插件小时触发插件的重新加载。



我正在考虑类似于:

  $(窗口).resize(function(){
//重新加载插件
});

希望你们有一个能够以正确方式引导我的解决方案。

解决方案

所以在阅读了facebook web sdk的文档后,我发现了这个重新加载iframe的小函数。

  FB.XFBML.parse(); 

https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse



<这解决了我的问题,但@LucaGiardina也提供了一个很好的解决方案,但我认为如果存在,它总是使用内置函数的上帝实践。


So I am using the new Facebook plugin (Page Plugin) and have a hard time to get it responsive on window resize.

I have set the option data-adapt-container-width="true", but that only triggers when there i a page load/reload.

Please se my JSFiddle: http://jsfiddle.net/29zgc790/ (try it in exporer and if that dont work try my plunker: http://plnkr.co/edit/IPnjpJUXxkO4WTLFTTW0?p=preview) where i have set the start width for the plugin to max (500px), but I want to trigger a reload of the plugin when the container (window) gets smaller then the plugin at that particular time.

I am thinking about somthing like:

$(window).resize(function () {
    //Do the reload of plugin
});

Hope you guys have an idea of an solution that can guid me in the right way.

解决方案

So after reading the documentation for the facebook web sdk I found this little function that reloads the iframe.

FB.XFBML.parse();

https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse

That solved my problem, but @LucaGiardina hade a good solution as well but I think its always a god practice to use the built in functions if thay exist.

这篇关于使Facebook插件响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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