简体   繁体   English

后退按钮后jQuery脚本未准备好

[英]jQuery scripts not ready after back button

I try make web like github with PJAX. 我尝试使用PJAX使网络像github。 Page works normal if use PJAX links. 如果使用PJAX链接,则页面正常运行。 Problem is if click back button. 问题是单击后退按钮。 Content is loaded, but jquery scripts are not ready. 内容已加载,但jquery脚本尚未准备好。 Go to http://test.hopeseeker.com/ , go down and click on emotion (Loved) page is loaded with PJAX. 转到http://test.hopeseeker.com/ ,然后单击加载了PJAX的情感(已爱)页面。 Then click back button on browser. 然后在浏览器上单击后退按钮。 Index is loaded, but jQuery is not ready. 索引已加载,但jQuery尚未就绪。

To load the jquery added in your page, you need to call it after the pjax event is completed. 要加载添加到页面中的jquery,您需要在pjax事件完成后调用它。

To make it work also on browser's back/ forward button clicks, you can use pjax-end event. 要使其在浏览器的后退/前进按钮单击中也起作用,可以使用pjax-end事件。

$("#pjax_container_id").bind('pjax:end', function() {
  // call your jquery functions
});

Hope this would help you. 希望这对您有帮助。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM