Created
August 15, 2013 22:05
-
-
Save dux/6245402 to your computer and use it in GitHub Desktop.
Memorize jQuery and DOM init states
This file contains hidden or 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
$.memento = (func) -> | |
if typeof func == 'function' | |
console.log '$.memento :store' | |
$.memento_stack ||= [] | |
$.memento_stack.push func | |
$ -> func() | |
unless func | |
console.log '$.memento :reattach' | |
setTimeout -> | |
for func in $.memento_stack | |
func() | |
, 100 | |
# $.memento -> # store and fire | |
# $('.drag').draggable() | |
# | |
# after Pjax | |
# $.memento() # fire memoized | |
# | |
# | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment