我在我的站點中使用jQuery Masonry來顯示博客文章。並且每個帖子塊都添加了Facebook評論框。當有新的評論時,容器div擴展,不幸的是與下面的一個重疊。在這種情況下,我需要重新運行砌體腳本來重新加載塊。 如何檢查div的高度來重新排列div塊
所以我使用Ben Alman's Jquery Resize Event Plugin檢查在div的高度變化,這樣的砌體腳本根據新的大小重新定位塊,避免重疊。
雖然它不工作,並且當我用螢火蟲檢查它時似乎沒有錯誤。我是Jquery的新手,我希望我只是在這裏犯了一個簡單的錯誤。
如果你想看看它,請檢查bjk-tribun.com 當你在評論框中輸入一些評論時,你會看到重疊。
$(function(){
// Bind the resize event. When any test element's size changes, update its
// corresponding info div.
var iframe = $(".fb_iframe_widget");
// Called once the Iframe's content is loaded.
iframe.load(function(){
// The Iframe's child page BODY element.
var iframe_content = iframe.contents().find('body');
// Bind the resize event. When the iframe's size changes, update its height as
// well as the corresponding info div.
iframe_content.resize(function(){
var elem = $(this);
// Resize the IFrame.
iframe.css({ height: elem.outerHeight(true) });
$('#sort').masonry(reloadItems);
// Resize the Iframe and update the info div immediately.
iframe_content.resize();
});
});