【发布时间】:2016-03-25 19:35:17
【问题描述】:
我有一个在调整窗口大小时被调用的函数
$(window).resize(setVideoElements);
该函数设置视频缩略图容器类的高度
var setVideoElements = function () { setElementsHeight('.videothumbnail'); };
function setElementsHeight(selector) {
console.log('setting Max element height');
// Get an array of all element heights
var elementHeights = $(selector).map(function () {
return $(this).height();
}).get();
// Math.max takes a variable number of arguments
// `apply` is equivalent to passing each height as an argument
var maxHeight = Math.max.apply(null, elementHeights);
// Set each height to the max height
$(selector).height(maxHeight);
}
这个函数工作正常,只是它的触发太快了
<div class="thumbnail videothumbnail">
<a href="@Url.Action("Video", new { ID = Video.ID })">
<img class="videoThumbnailImg" src="@Video.ThumbnailUrl" alt="">
</a>
<div class="caption">
<h3>@Video.Name</h3>
@foreach (var tag in Video.TagsToVideos)
{
<span><a href="#">@tag.Tag.Name</a></span>
}
<p>@Video.Description</p>
</div>
问题是该函数在图像调整大小之前触发。在所有图像都已调整大小后,我需要触发调整大小功能。
有谁知道在所有图像都调整大小后如何触发此功能一次?
【问题讨论】:
标签: javascript c# model-view-controller razor