Anthony
Anthony

Reputation: 35938

how to hide spinner after the content loads

I'm using pjax to load content and while the content is loading, I show a spinner:

$('a[data-pjax]').pjax().live ("click", function () {
    $("#loader").show();
});

This works fine, however, after the content loads the loader still stays there.

Where should I call $(#loader).hide() to hide the loader after the content has loaded?

Upvotes: 0

Views: 1765

Answers (2)

Dragu
Dragu

Reputation: 3297

According to the doc https://github.com/defunkt/jquery-pjax

$(document).on('pjax:complete', function() {
  $("#loader").hide()
})

I think you can also use pjax:end event.

Upvotes: 3

Optimus Prime
Optimus Prime

Reputation: 6907

of course after the content loads, after your ajax call within the success function.

$.ajax({
          url: "test.html",
          data: {parameter:parameter},
          }).done(function() {
               //on return, add here
               $("#loader").hide()
          });

Upvotes: 2

Related Questions