See this demo from Filament Group using their Progressive Enhancement enhance.js library
Modifying to give :-
<script type="text/javascript" src="../_shared/EnhanceJS/enhance.js"></script>
<script type="text/javascript">
// Run capabilities test
enhance({
loadScripts: [
{src: 'js/excanvas.js', iecondition: 'all'},
'../_shared/jquery.min.js',
'js/visualize.jQuery.js',
'js/example.js'
],
loadStyles: [
'css/visualize.css',
'css/visualize-dark.css'
]
});
alert($);
</script>
I get an "$ is undefined error" on the alert presumably because jQuery has not loaded yet.
Note - the alert($) is just for debugging - I am trying to do something with that e.g. $('some-selector') - and no $(handler) or $(document).ready etc don't work either - jquery is not loaded, $ is not defined.
enhance's onScriptLoaded looks like it should do he trick but if I add in
onScriptsLoaded:[runMyCode()]
and later
function runMyCode()
{
alert("runMyCode was called");
alert($);
}
The first alert works but $ is still not defined.
If I call runMyCode on a click event of a button it does work.
So the question is - how can you run code once all scripts have finished loading with enhance.js?
P.S. Same problem verified in IE8/FF3/Chrome7