0

I have a views block with an infinite scroll (using Views Bootstrap and Views Infinite Scroll modules). The block displays cards and I want them to have the same height. jQuery Auto Height does that well. However, it only happens for the initial load. Auto Height has no way of knowing to fire on subsequent Ajax calls. What is the best way to integrate them so that Auto Height is called on each infinite scroll Ajax call?

1 Answer 1

0

If you take a look at the source for the jQuery Auto height module, there appears to be an AutoHeight() method that you can call on a given jQuery object.

$(drupalSettings.auto_height.selectors).AutoHeight();

And in the source for Views Infinite Scroll, we can see that an event, scroll.views_infinite_scroll, is available to listen in on. The portion of Views Infinite Scroll's code that invokes this event is:

$window.on(scrollEvent, debounce(function () {
  if (isLoadNeeded()) {
    $pager.find('[rel=next]').click();
    $window.off(scrollEvent);
  }
}, 200));

Using the above as a template, I think you could invoke the AutoHeight() method every time a new view is added.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.