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);
}
});
嗨,我使用上面的代码来为bootstrap创建相等的高度列,它可以工作。但我也使用无限滚动库来加载更多内容,在我向下滚动脚本后没有加载新列时,我知道这是因为脚本加载后ajax正在加载。我知道.ajaxComplete()句柄可以使这个工作,但我找不到正确的方法。
答案 0 :(得分:2)
我不确定我的问题是否正确,但您可能需要检查$.getScript()
函数并在完成ajax调用后使用它:
$.ajax({
// rest of the code
complete: function() {
$.getScript("path/to/script.js", function() {
alert('All done!');
});
}
})
希望这会有所帮助!