Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
118
rated 0 times [  124] [ 6]  / answers: 1 / hits: 18502  / 9 Years ago, wed, may 6, 2015, 12:00:00

I'm using Facebook's Page Plugin widget. On Facebook's page, it is written:




If you want to adjust the plugin's width on window resize, you manually need to rerender the plugin.




How can I dynamically change this plugin's width without page refreshing (with, for example, Firefox responsive view - CTRL+M shortcut).



And yeah, I have read THIS post, but none of these solutions tells how to rerender the plugin.


More From » php

 Answers
16

For JavaScript/jQuery approach, you may want to listen to on window resize event and reload the Facebook Page Plugin Div container. Make sure that the FB Page plugin is wrapped around a parent div so we can use its size when we reload the div.



<div id=pageContainer>
<div class=fb-page data-href=https://www.facebook.com/facebook data-width=500 data-height=250 data-small-header=false data-adapt-container-width=true data-hide-cover=false data-show-facepile=true data-show-posts=true><div class=fb-xfbml-parse-ignore><blockquote cite=https://www.facebook.com/facebook><a href=https://www.facebook.com/facebook>Facebook</a></blockquote></div></div>
</div>

$( window ).resize(function() {
var container_width = $('#pageContainer').width();
$('#pageContainer').html('<div class=fb-page data-href=https://www.facebook.com/facebook data-width=' + container_width + ' data-height=250 data-small-header=false data-adapt-container-width=true data-hide-cover=false data-show-facepile=true data-show-posts=true><div class=fb-xfbml-parse-ignore><blockquote cite=https://www.facebook.com/facebook><a href=https://www.facebook.com/facebook>Facebook</a></blockquote></div></div>');
FB.XFBML.parse();
});

[#66714] Tuesday, May 5, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
travion

Total Points: 137
Total Questions: 96
Total Answers: 103

Location: India
Member since Wed, Aug 4, 2021
3 Years ago
travion questions
Mon, Dec 16, 19, 00:00, 5 Years ago
Sat, Oct 19, 19, 00:00, 5 Years ago
Fri, Sep 20, 19, 00:00, 5 Years ago
Wed, Nov 14, 18, 00:00, 6 Years ago
Sun, Oct 28, 18, 00:00, 6 Years ago
;