Last active
August 29, 2015 13:57
-
-
Save markselby/9622164 to your computer and use it in GitHub Desktop.
Running Javascript after render.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Somewhere in your javascript assets included at the end of the document | |
$(document).ready(function() { | |
loaded = true; | |
doInit(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- In the document head --> | |
<script> | |
var initFuncs=[], loaded = false; | |
function onInit(f) { initFuncs.push(f); if(loaded) doInit(); } | |
function doInit() { var f; while(f = initFuncs.shift()) { f(); }} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- In an html template somewhere --> | |
<script> | |
onInit(function() { alert('My favourite cheese is ' + this); }.bind('Brie'); ); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment