1

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 !

2 Answers 2

3

Try this:

Add an ajaxComplete function

   $( document ).ajaxComplete(function() {
      $('h2').text('filters');
    });
3
  • I edit my post btw, It does not work Commented Jan 7, 2016 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
    Commented Jan 8, 2016 at 1:21
  • It works for me. Commented Oct 29, 2018 at 20:45
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);
1
  • 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
    Commented Jan 28, 2016 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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