Skip to content

Instantly share code, notes, and snippets.

@czajkovsky
Created August 6, 2014 15:44
Show Gist options
  • Save czajkovsky/ddc20ea2adad0a5ffd31 to your computer and use it in GitHub Desktop.
Save czajkovsky/ddc20ea2adad0a5ffd31 to your computer and use it in GitHub Desktop.
window.PG =
RailsViews: {}
initCurrentView: ->
if @currentView?
@currentView.undelegateEvents()
@currentView = null
$container = $('body')
viewName = $container.data('view')
viewIdName = $container.data('view-id')
specificViewName = "#{viewName}#{viewIdName}View"
generalViewName = "#{viewName}View"
if PG.RailsViews[specificViewName]?
@currentView = new PG.RailsViews[specificViewName]()
else if PG.RailsViews[generalViewName]?
@currentView = new PG.RailsViews[generalViewName]()
initCommonView: ->
new PG.RailsViews.CommonView()
$ ->
PG.initCommonView()
PG.initCurrentView()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment