Skip to content

Instantly share code, notes, and snippets.

@kormie
Created September 27, 2012 16:06
Show Gist options
  • Select an option

  • Save kormie/3794850 to your computer and use it in GitHub Desktop.

Select an option

Save kormie/3794850 to your computer and use it in GitHub Desktop.
My method for page specific JS
window.FooPageJavaScript = class FooPageJavaScript
constructor: ->
@setupPage()
@bindEvents()
module ApplicationHelper
def load_page_specific_javascript_class(javascript_class)
content_for :javascript do
javascript_tag "$(function(){ new #{javascript_class} })"
end
end
end
# A call to yield: javascript is placed at the bottom of the application layout file
- load_page_specific_javascript_class "FooPageJavaScript"
@phillc
Copy link

phillc commented Apr 22, 2014

I've improved on it slightly since then ;) https://gist.github.com/phillc/11184246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment