Use matchHeight behavior on elements injected via Ajax

am 10.01.2017 - 15:39 Uhr in
Hi there. I am having problems figuring out a convenient way to adjust the height attributes of Html elements that are injected on a successful AJAX request (e.g. a search request via Elastic Search). To change the height i am using jQuery's matchHeight function within the Drupal environment. Therefore it is initialized through Drupal's behavior:
(function($, Drupal) {
'use strict';
Drupal.behaviors.matchheightInit = {
attach: function(context, settings) {
$('DIV_1, DIV_2', context).once().matchHeight();
}
}
})(jQuery, Drupal);
Obviously this is not working when 'DIV_1' and 'DIV_2' are injected through an AJAX call after the page is loaded. I tried:
...
Drupal.behaviors.matchheightInit = {
attach: function(context, settings) {
$(document).ajaxComplete(function(){
$('DIV_1, DIV_2', context).once().matchHeight();
});
}
}...
But that is not really what i want. I really just need to access the height attribute within the initiation of that behavior for elements that are injected after a succesful AJAX request. Is that even possible respectively the right place to do that?
Regards
- Anmelden oder Registrieren um Kommentare zu schreiben
Neue Kommentare
vor 1 Tag 2 Stunden
vor 1 Tag 5 Stunden
vor 1 Tag 5 Stunden
vor 1 Tag 6 Stunden
vor 3 Tagen 1 Stunde
vor 5 Tagen 3 Stunden
vor 5 Tagen 6 Stunden
vor 5 Tagen 21 Stunden
vor 4 Tagen 7 Stunden
vor 5 Tagen 23 Stunden