オブジェクトを垂直方向にサイズ変更するための単純な JS プラグインを作成しています。サイズ変更イベントまでは正常に機能します-すべてのバインドの初期関数$flexParentの最後として設定されているようです。そのため、3 つの「flexParents」がプラグインに渡された場合、最後の 1 つだけがサイズ変更イベントで処理されます。わずか3回。明らかに、ここでバインディングを誤解していますが、明確にしていただければ幸いです。$flexParent.each()
(関数($){
$.fn.flexHeight = 関数 (オプション) {
if (!options){options = {};}
変数設定 = $.extend({
ボックス: false
}、オプション);
関数 main(flexParent) {
var $flexParent = flexParent;
if (settings.boxes) {
$children = $flexParent.find(settings.boxes);
} そうしないと {
$children = $flexParent.children
}
var maxHeight = 0;
$children.each(関数() {
$(this).height('auto');
});
$children.each(関数() {
maxHeight = maxHeight > $(this).outerHeight(false) ? maxHeight : $(this).outerHeight(false);
});
$children.each(関数() {
$(this).height(maxHeight);
});
}
return this.each(function() {
$flexParent = $(これ);
メイン ($flexParent);
$(window).resize(関数() {
メイン ($flexParent);
});
});
}
}(jQuery));