下面是我的 JavaScript 代码,我遇到了一个问题,希望有人能帮助我。在我调整实际浏览器窗口的大小之前,函数 columnConform 不会触发并调整 div 的大小。所以该功能正在工作,但直到我触发窗口调整大小事件处理程序才发生。加载所有页面内容和 DOM 后,我该怎么做才能触发该函数?提前致谢!
$(document).ready(function() {
$(function(){
jumboSlide();
columnConform();
});
function jumboSlide() {
$('#jumboSlide').carousel()
}
function resetHeight() {
$('.row-equal > div').css("min-height", 0);
}
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array();
function setConformingHeight(element, newHeight) {
element.css("min-height", newHeight);
}
function getOriginalHeight(element) {
return (element.data("originalHeight") == undefined) ? (element.outerHeight()) : (element.data("originalHeight"));
}
function columnConform() {
$('.row-equal > div').each(function() {
var $element = $(this);
var topPosition = $element.position().top;
if (currentRowStart != topPosition) {
for(currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) setConformingHeight(rowDivs[currentDiv], currentTallest);
rowDivs.length = 0;
currentRowStart = topPosition;
currentTallest = getOriginalHeight($element);
rowDivs.push($element);
} else {
rowDivs.push($element);
currentTallest = (currentTallest < getOriginalHeight($element)) ? (getOriginalHeight($element)) : (currentTallest);
}
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) setConformingHeight(rowDivs[currentDiv], currentTallest);
});
}
$(window).resize(function(){
resetHeight();
columnConform();
});
});