Skip to content

Commit

Permalink
added some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ejschmitt committed Sep 7, 2009
1 parent ca227d1 commit b1fa63c
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions README
Original file line number Original file line Diff line number Diff line change
@@ -1,13 +1,40 @@
Jsvars Jsvars
====== ======
Requires Json (require 'json')


Introduction goes here. This rails plugin will hide the messiness of passing variables from rails into javascript. It will automatically add the js needed to create a variable you define in rails, or add variables to objects.




Example Example
======= =======


Example goes here. in your controller:


jsvars[:loginPath] = login_path
- Will create a global variable in the JS window object named 'loginPath' with the value you assigned.


Copyright (c) 2009 [name of plugin creator], released under the MIT license jsvars[:myObject] = {:title => "My Page", :email => "me@example.com"}
- Adds the object variables that can be used as myObject.title & myObject.email in the view javascipt.
- This will add the object "myObject" if it does not exist, if it already does, only the variables will be added to the already existing object.

Example of extending an object:
In controller:
jsvars[:login] = {:path => '/login'}

in view:
<script>
var login = {
loginFuntion: function () {
// ....
},
specialVar: "My special Var"
};
</script>

in JS:
login.loginFunction = function()
login.specialVar = 'My special Var'
login.path = '/login'


Copyright (c) 2009 Erick Schmitt, released under the MIT license

0 comments on commit b1fa63c

Please sign in to comment.