lib/assets/javascript/init.js.coffee in initjs-0.1.3 vs lib/assets/javascript/init.js.coffee in initjs-1.0.0

- old
+ new

@@ -5,14 +5,20 @@ controllerName = infos.data("controller-name") action = infos.data("action") this.execFilter('init') this.exec(controllerClass, controllerName, action) this.execFilter('finish') + this.appName() + appName: -> + appName = $("#init-js").data('app-name') || "App" + window.App = window[appName] + if window.App is undefined + console.log "Initjs: #{appName} is not defined. Run `rails generate initjs` for generates the app file." + exec: (controllerClass, controllerName, action) -> namespace = App - if controllerClass railsNamespace = controllerClass.split("::").slice(0, -1) else railsNamespace = [] @@ -23,9 +29,10 @@ controller = namespace[controllerName] if controller and View = controller[action] App.currentView = window.view = new View() execFilter: (filterName) -> + this.appName() if App.Common and typeof App.Common[filterName] == 'function' App.Common[filterName]() jQuery -> window.Initjs.execFilter('initPage') # If you are using the Turbolinks and you need run a code only one time.