Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created January 10, 2018 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaskills/8eabf6df1b144f4fcf2c9cc3c28e387b to your computer and use it in GitHub Desktop.
Save metaskills/8eabf6df1b144f4fcf2c9cc3c28e387b to your computer and use it in GitHub Desktop.
Turbolinks & jQuery ReConstructor Pattern
class Toolbar
constructor: ->
document.addEventListener 'turbolinks:before-cache', @turboBeforeCache
@reConstructor()
reConstructor: ->
@registerWaypoint()
registerWaypoint: ->
# ...
turboBeforeCache: (e) =>
# ...
document.addEventListener 'turbolinks:load', ->
ProductCatalog.Toolbar?.reConstructor()
jQuery ->
ProductCatalog.Toolbar = new Toolbar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment