javascript - jQuery loaded through JS in head -


i'm using jquery , jquery mobile build application. load jquery , jquery mobile dynamically through script in head. body uses jquery ($) in script cannot access loads asynchronously. how can load jquery in synchronously or approach resolving problem?

thanks in advance

you might want @ head.js. asynchronously loads scripts, , gives ready function, similar jquery's, can put of onload code.

<head> ... <script src="/js/head.js"></script> <script>     head.js('/js/jquery.js', '/js/jquery-mobile.js', function() {         $(document).ready(function() {             // write code!         })     }); </script> ... </head> 

if need javascript elsewhere, can use head.ready()

<script>     head.ready(function() {         $(document).ready(function () {             // write more code!         });     }); </script> 

which can go anywhere in html.

note: head.js examples don't use jquery's $(document).ready() inside of head.ready(), recall running problem without it. may have fixed it, including doesn't hurt anything.

update: noted in comments, jquery mobile, should use $(document).bind('pageinit') in place of $(document).ready().


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -