【发布时间】:2016-05-22 22:55:41
【问题描述】:
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$('.blocks').each(function() {
$el = $(this);
topPosition = $el.position().top;
if (currentRowStart != topPosition) {
// we just came to a new row. Set all the heights on the completed row
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
// set the variables for the new row
rowDivs.length = 0; // empty the array
currentRowStart = topPosition;
currentTallest = $el.height();
rowDivs.push($el);
} else {
// another div on the current row. Add it to the list and check if it's taller
rowDivs.push($el);
currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
}
// do the last row
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
});
嗨,我正在使用上面的代码为引导程序创建等高的列,它可以工作。但是我也在使用无限滚动库来加载更多内容,并且在我向下滚动后,脚本没有加载到新列中,我知道这是因为 ajax 在脚本加载后加载。我知道 .ajaxComplete() 句柄应该可以完成这项工作,但我还没有找到正确的方法。
【问题讨论】:
标签: jquery ajax infinite-scroll