Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After page refresh jquery stops working

That's realy strange issue, i have quite a lot of plugins and custom scripts in my page and normaly it all works just fine, but if i would try to refresh page, not just click on some link, some of my scripts just stops working, mostly the ones who is changing css properties, my firebug doesn't show any errors, what could be causing something like that?

like image 860
Linas Avatar asked Feb 05 '12 14:02

Linas


2 Answers

Answer from original poster:

So the problem was that i used $(document).ready() what i realy needed was $(window).load()

like image 68
Trott Avatar answered Sep 20 '22 10:09

Trott


I know this is an old question I stumbled upon. Anyway, my answer might help another when the same problem arises. Unfortunately I haven't got the reputation to comment on Trott's answer above.

That being said, if you are using jQuery 1.8 or any version after his, then use $(window).on('load', function() { ... });. The $(window).load() was deprecated in jQuery version 1.8 and will throw the error jquery url.indexOf is not a function (at least in jQuery 3.4.1)

like image 41
M. Groenhout Avatar answered Sep 24 '22 10:09

M. Groenhout