README.md in initjs-1.0.0 vs README.md in initjs-1.0.1

- old
+ new

@@ -12,51 +12,51 @@ ### Simple javascript functions ```coffee # app/assets/javascripts/app_name/posts/new.js.coffee -AppName.Posts = {} if AppName.Posts is undefined +AppName.Posts ?= {} -AppName.Posts.New =-> +AppName.Posts.New = -> # Javascript for the page "posts/new" ``` ```coffee # app/assets/javascripts/app_name/posts/show.js.coffee -AppName.Posts = {} if AppName.Posts is undefined +AppName.Posts ?= {} -AppName.Posts.Show =-> +AppName.Posts.Show = -> # Javascript for the page "posts/1" ``` ```coffee # app/assets/javascripts/app_name/blog/posts/show.js.coffee -AppName.Blog = {} if AppName.Blog is undefined -AppName.Blog.Posts = {} if AppName.Blog.Posts is undefined +AppName.Blog ?= {} +AppName.Blog.Posts ?= {} -AppName.Blog.Posts.Show =-> +AppName.Blog.Posts.Show = -> # Javascript for the page "blog/posts/1" ``` ### Using Backbone.js ```coffee # app/assets/javascripts/app_name/posts/new.js.coffee -AppName.Posts = {} if AppName.Posts is undefined +AppName.Posts ?= {} AppName.Posts.New = Backbone.View.extend # Javascript for the page "posts/new" ``` ```coffee # app/assets/javascripts/app_name/posts/show.js.coffee -AppName.Posts = {} if AppName.Posts is undefined +AppName.Posts ?= {} AppName.Posts.Show = Backbone.View.extend # Javascript for the page "posts/1" ``` ```coffee # app/assets/javascripts/app_name/blog/posts/show.js.coffee -AppName.Blog = {} if AppName.Blog is undefined -AppName.Blog.Posts = {} if AppName.Blog.Posts is undefined +AppName.Blog ?= {} +AppName.Blog.Posts ?= {} AppName.Blog.Posts.Show = Backbone.View.extend # Javascript for the page "blog/posts/1" ``` @@ -82,13 +82,16 @@ Make sure initjs generator has injected `//= require app_name/app_name.js` and `//= require init.js` to your Javascript manifest file (usually found at `app/assets/javascripts/application.js`). ## Usage -Include the Initjs tag in your application layout (usually found at `app/view/layouts/application.html.erb`) after the body tag. +Include the Initjs tag in your application layout (usually found at `app/view/layouts/application.html.erb`) right after the opening of the body tag. ```erb -<%= initjs_tag app_name: "AppName" %> + <body> + <%= initjs_tag app_name: "AppName" %> + … + </body> ``` ### The app file If you have a commom javascript that you need execute every page, you can put in `app/assets/javascripts/app_name/app_name.js.coffee` \ No newline at end of file