Skip to content

Instantly share code, notes, and snippets.

@dux
Created August 15, 2013 22:05
Show Gist options
  • Save dux/6245402 to your computer and use it in GitHub Desktop.
Save dux/6245402 to your computer and use it in GitHub Desktop.
Memorize jQuery and DOM init states
$.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