Most of the times, I put some javascript code in $(document).ready to do some initialization stuffs on the page, like event binding, etc.
But now I would like to use pjax https://github.com/defunkt/jquery-pjax for some of my pages.
With pjax, because there’s only part of the page gets refreshed, $(document).ready will not get called again.
I could manually trigger the initializing script on event pjax:end, but I also want to know if there’s a better solution for that.
Thanks.
I think your best bet is probably just to do what you said and hook your page specific init code up to the “pjax:end” event. That way it’ll essentially be doing the same job that it did before and run against whatever html has been loaded in to the DOM.