在试图隐藏某些项目的<li>
之后,我试图第二次调用jQuery.matchHeights函数。该插件可以在初始页面加载时在所有项目上正常运行,但不会在第一次“过滤器”点击时触发-但是,如果我第二次单击同一<li>
,则该插件会按预期触发(并将matchHeights应用于过滤的项目)-我在做什么错了?
app.js:
var AppView = Backbone.View.extend({
el: 'body',
initialize: function() {
...
//run initial matchHeight function -- this works!
$('.work-item .text-container').matchHeight();
//when a filter link is clicked...
$('ul.filter-menu li').bind('click', function(e) {
... other filtering code ...
// Show filtered items
$(filteredItems).css('display','block');
// remove initial matchHeight bindings
var allItems = $('.work-item .text-container');
$(allItems).matchHeight({ remove: true });
// re-apply matchHeights to filtered items -- this DOESN"T WORK!
var filteredTextareas = $(filteredItems).find('.text-container');
$.fn.matchHeight._apply(filteredTextareas);
... other filtering code ...
return false;
});
}
});
module.exports = AppView;