Skip to content

Instantly share code, notes, and snippets.

@biscuitvile
Forked from henrik/example.coffee
Created September 4, 2013 03:03
Show Gist options
  • Save biscuitvile/6432339 to your computer and use it in GitHub Desktop.
Save biscuitvile/6432339 to your computer and use it in GitHub Desktop.
# Code:
$ -> # a.k.a. jQuery.ready ->
$("#hash-value-when-page-loaded").text(location.hash)
# Test:
location.hash = "foo"
fakeDomReady()
$("#hash-value-when-page-loaded").text().should.equal "#foo"
# Wrap jQuery.ready so we can trigger it in
# our mocha tests, which replace the body after
# the original ready event.
window.domReadyFunctions = []
window.fakeDomReady = ->
fn() for fn in domReadyFunctions
$.fn.oldReady = $.fn.ready
$.fn.ready = (fn) ->
domReadyFunctions.push(fn) if fn
$.fn.oldReady.apply(this, arguments)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment