:
When using AJAX to do the drawer effect, when the second Ajax extract page, JS did not reload, how to solve the problem?
Reply content:
:
When using AJAX to do the drawer effect, when the second Ajax extract page, JS did not reload, how to solve the problem?
My blog used a similar pjax
technique, and the design encountered a similar problem.
In fact, the root cause is not JS does not reload, in fact, he does not need to reload, because it has been loaded.
The root cause is that it will not be re-executed.
You can define a file called bootstrap.js
.
And then re-execute one at a time to re-load the JS can be.
PS If you have previously written code in a common area, that is not part of any function, you need to encapsulate it yourself into a function and execute it here.
Like what:
A.js
console.log('test');
This JS is actually loaded, also executed, under normal circumstances will not be executed again.
Then you need to modify it to
A.js
var initAJs=function(){ console.log('test');}
Then execute the Pjax when it returns successfully.
initAjs
Can.