0

So I created a view listing all the users. I implement a search form with autosubmit function.

The autosubmit works with an ajax script.

Into my page view, I changed a few things in Jquery like this (main.js) :

$(document).ready(function(){
    //code for others pages.....
});

$(document).ajaxComplete(function(){
   $('h2').text('filters');
});

But when I filter my list of users, the ajax script is loading and after that, Jquery changes do not appear due to ajax load.

Do you know a trick to keep Jquery changes when ajax script is loading ?

Thanks for your help !

3

Find the solution below:

(function($) {
  Drupal.behaviors.events = {
    attach: function(context, settings) {
      $('#views-exposed-form-recherche-artiste-page', context).ajaxSuccess(function(){
         $('h2').text('filters');
      });
    }
  };
})(jQuery);
  • Tried your solution but it still not working for me. Should i change something else apart from my view ID? i'm using Views Load More, and my code doesn't work after getting more news in my view – xstean Jan 28 '16 at 14:03
1

Try this:

Add an ajaxComplete function

   $( document ).ajaxComplete(function() {
      $('h2').text('filters');
    });
  • I edit my post btw, It does not work – Corentin Branquet Jan 7 '16 at 15:15
  • @CorentinBranquet I assumed you were just focusing on the snipped rather than the entire code. Since I thought you got the document ready function to work. – No Sssweat Jan 8 '16 at 1:21
  • It works for me. – usmanjutt84 Oct 29 '18 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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