Last active
August 29, 2015 13:57
-
-
Save mathias/9436464 to your computer and use it in GitHub Desktop.
An on-ready handler for Hoplon pages; works but not the most elegant. (added .clj to filename to make gist syntax highlight)
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
(page "onready.html") | |
(defn doc-ready-handler [] | |
;; do some stuff after page is loaded and ready | |
) | |
(defn on-ready [fn] | |
(aset js/document | |
"onreadystatechange" | |
(fn [] | |
(let [ready-state (. js/document -readyState)] | |
(when (= "complete" ready-state) | |
(fn)))))) | |
(html | |
(head | |
(on-ready doc-ready-handler)) | |
(body)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment