Use matchHeight behavior on elements injected via Ajax
Eingetragen von Sepr (1)
am 10.01.2017 - 15:39 Uhr in
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 11 Stunden 6 Minuten
vor 14 Stunden 29 Minuten
vor 14 Stunden 28 Minuten
vor 15 Stunden 57 Minuten
vor 16 Stunden 17 Minuten
vor 16 Stunden 23 Minuten
vor 17 Stunden 42 Minuten
vor 18 Stunden 4 Minuten
vor 18 Stunden 30 Minuten
vor 18 Stunden 54 Minuten