README.md in happy_place-0.0.2 vs README.md in happy_place-0.0.3
- old
+ new
@@ -32,19 +32,23 @@
Or install it yourself as:
$ gem install happy_place
## Features
-happy_place adds a js method to your controller. This method accepts the following keyword arguments:
+happy_place adds a js method to your controller.
-`js_class:` String name of the js class that you want to user
+It is important to note that this is not a breaking change to your controller. All controllers should work normally when adding this gem. This will allow you to test out happy place and see if you like it without breaking the rest of your app and if you do like it you can gradually make the changes to using the js method for all your js needs.
+The `js` method accepts the following keyword arguments:
+
+`js_class:` String name of the js class that you want to use
+
`function:` Sting of the name of the function you would like to call
-`partial:` String of the partial name and path that you would like to render
+`partials:` Hash of keyword arguments with partials that will be rendered and available in your js function
-`args:` Hash of arguments that you would like to be available in your js function
+`args:` Hash of keyword arguments that you would like to be available in your js function
Both partial and keys passed from args will be available in your js function by accessing the object passed in.
```ruby
class ExampleContorller
@@ -53,11 +57,11 @@
respond_to do |format|
format.js {
js(js_class: "ExampleClass",
function: "doSomething",
- partial: "some_partial",
+ partials: {some_partial: "some_partial"},
args: {first_id: @examples.first.id}
)
}
format.html
end
@@ -68,11 +72,11 @@
```coffeescript
class this.ExampleClass
constructor: ->
@doSomething: (args) ->
- html_to_append = args.partial
+ html_to_append = args.some_partial
first_id = args.first_id
alert(html_to_append)
alert(first_id)
```
@@ -84,11 +88,11 @@
@examples = Example.all
respond_to do |format|
format.js {
js(
- partial: "some_partial",
+ partials: {some_partial: "some_partial"},
args: {first_id: @examples.first.id}
)
}
format.html
end
@@ -123,11 +127,11 @@
```coffeescript
class this.ExampleController
constructor: ->
@index: ->
- alert "Huzza!)
+ alert "Huzza!"
```
## Naming and Directory Structure
Technically you can put your code anywhere you want but to make it to your happy place you should follow the naming and directory structure used by rails.
@@ -221,11 +225,11 @@
class PostsController
def index
@posts = Posts.all
respond_to do |format|
- format.js { js partial: "posts" }
+ format.js { js partials: {posts: "posts"} }
format.html
end
end
end
```
@@ -235,10 +239,10 @@
```ruby
class this.PostsController
constructor: ->
@index: (args) ->
- $(".posts_table").html(args.partial);
+ $(".posts_table").html(args.posts);
```
Step 4. Add `assets/controllers` to your manifest application.js
```