1

To start with, my goal was to alter the ajax loading behavior in views exposed filter (Druapl 7 and Views 7.x-3.3) and this question pretty much sorted that one out: How do I change the ajax loading behaviour in Views?

Here comes the problem, the jQuery .ajaxStart and .ajaxSuccess doesn't seem to fire when i change the exposed filter in the view. I get my custom.js file to load correctly and this simple code works just fine:

(function($) {
  Drupal.behaviors.seven_doublemthemes = {
    attach: function(context, settings) {

      alert('message');

    }
  };
})(jQuery);

but replacing my alert message with this does not:

$('#views-exposed-form-produkter-3-kol-page', context).ajaxStart(function(){
        $('#views-exposed-form-produkter-3-kol-page,div.view-id-produkter_3_kol', context).fadeTo(300, 0.5);
      });
      $('#views-exposed-form-produkter-3-kol-page', context).ajaxSuccess(function(){
         $('#views-exposed-form-produkter-3-kol-page', context).fadeTo(300, 1.0);
         $('div.view-id-produkter_3_kol', context).css('opacity', 0.5).fadeTo(300, 1.0);
      });

I have also tried to use $(document).ajaxStart without success. The fading also works if i remove the ajaxStart and allow it to fade when page is loaded.

So, if i could get the ajaxStart and Success to fire, everything else should work like I wanted it.

(This is my first question here, so I hope I've managed to do it the right way)

  • Welcome to Drupal Answers, your question is exemplary so don't worry about that :) Are you able to share a live link to the site you're working on? It's difficult to debug client-side stuff without being able to inspect the actual page – Clive Jul 7 '12 at 13:56
  • The site is unfortunately still on my local dev server.. Do you have any suggestions on how to debug ajax stuff? Haven't worked very much with it before. I am suspecting some interference with some other script on my site, maybe its a good idea to switch theme and see if that helps. I'm currently using a zen sub theme – Fredrik Jul 8 '12 at 20:50
  • Have you checked the console for any errors that might be happening before this code can be run? – Clive Jul 8 '12 at 21:04
  • No errors found in console. I have also tried to put some breakpoints in the jQuery script file where the ajaxStart and ajaxSuccess are located (at least i think I'm at the right place), but it never stops at that place. The view updates as it is supposed to when i change the exposed filters. – Fredrik Jul 8 '12 at 21:10
0

I found another js file that was causing the error, decided to live without it and everything works after removing it.

So, if someone encounter errors like this, change the the default theme and see if that solves the problem, then you know if the issue is within your custom theme or somewhere else.

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.