Sarajevo, Bosnia and Herzegovina

Jquery PJAX freeze

Well, we had an issue with pjax since all pjax calls have been finished with frozen page. Best way to illustrate “frozen page” is custom loader that is shown when pjax action is called and hided when pjax action finished its progress. But loader seems to stay on page, jquery functions don’t hide it and only after scrolling your page loader is removed. Strange isn’t it ?

First, it seams that pjax have some kind of collision with jquery .scrollTo(x) option. After removing that line of code the stuff seems to be ok. But then we had also another issue. Page jumps to top after pjax is loaded. Solution to this issue is to set properly pjax default values :

pjax.defaults = {
  timeout: 650,
  push: true,
  replace: false,
  type: 'GET',
  dataType: 'html',
  scrollTo: false,
  maxCacheLength: 20
}

Also you need to be careful with “pjax:send” or “pjax:end” functions, because its repeating (calling them twice – like we did accidently) can cause also pjax to freeze.

Happy coding 😉