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 4 Stunden
vor 1 Tag 5 Stunden
vor 1 Tag 9 Stunden
vor 1 Tag 16 Stunden
vor 3 Tagen 5 Stunden
vor 4 Tagen 7 Stunden
vor 4 Tagen 9 Stunden
vor 1 Woche 15 Stunden
vor 1 Woche 16 Stunden
vor 1 Woche 1 Tag