Use matchHeight behavior on elements injected via Ajax
Eingetragen von Sepr (1)
am 10.01.2017 - 16:39 Uhr in
am 10.01.2017 - 16: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 2 Tagen 12 Stunden
vor 2 Tagen 21 Stunden
vor 3 Tagen 1 Stunde
vor 3 Tagen 6 Stunden
vor 6 Tagen 22 Stunden
vor 1 Woche 15 Minuten
vor 1 Woche 13 Stunden
vor 2 Wochen 2 Tagen
vor 3 Wochen 4 Tagen
vor 4 Wochen 9 Stunden