jquery - Load javascript file every time a new page is loaded -


i'm using http://instantclick.io on website (a pjax jquery plugin) , i'm experiencing problems regarding javascripts. it's temperamental - page load scripting working fine, other times parts of scripts not run. also, scripts running more once. example, if set console log in .click() function, i'll see console log multiple times when there should one.

in instantclick.io documentation, explains how load script on each page load:

if have snippet of javascript need execute on every page change, use following: instantclick.on('change', yourcallback);

but need run whole js file rather function. have tried wrapping instantclick.on('change', function(){ around whole js file, scripts still not running again after new page opened.

in console, i'm seeing lots of errors relating functions being undefined, indicate files not being loaded each time.

how solve this? thanks!

write in callback code adding js file dynamically dom

  var jsfile=document.createelement('script');   jsfile.setattribute("type","text/javascript");   jsfile.setattribute("src", link);   document.getelementsbytagname("head")[0].appendchild(jsfile); 

and change link url path js file.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -