0

Here's my code:

// Reload screen after submission and completion of AJAX actions
$('.view-whiteboard, .view-whiteboard-full').ajaxStop(function() {
  location.reload();
});

I have this code operating in the frontend of my Drupal website but for some reason when I submit/save anything in the backend admin panel the above snippet of code makes the page reload.

I'm confused as to why it's doing this since I have defined the class names in the code that should be specific to the forms in the frontend.

Am I missing something in my above code that's making it so I'm triggering location.reload() on every form submission?

Any help would be great. Thanks--

user2266174
  • 15
  • 1
  • 6

1 Answers1

0

As of jQuery 1.8, the .ajaxStop() method should only be attached to document. You can get around this by creating a .click function that runs ajaxStop once:

$(document).ready(function(){
    $(".view-whiteboard, .view-whiteboard-full").click(function(){
        $(document).one("ajaxStop", function() {
            location.reload();
        });
    });
});

Otherwise, just separate the public vs admin theme so that they don't use the same javascript (must disable overlay module).

firewaller
  • 426
  • 2
  • 8
  • Hi Patrick. Thanks for the reply. Do you know what is the best method for separating js in public from admin when using the admin overlay module? So in other words: is it still possible to separate the js in public and admin when using that module? If not, do you know of another jQuery AJAX method I can use that will not target document and instead target only elements with a specific class name? – user2266174 Apr 30 '13 at 17:19
  • I tested a click function with a one time ajaxStop. That should do the trick. See edit above. – firewaller Apr 30 '13 at 18:38