Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added some documentation

  • Loading branch information...
commit b1fa63ccf441f170a23e0ffe668a577fc0e6c683 1 parent ca227d1
@ejschmitt authored
Showing with 30 additions and 3 deletions.
  1. +30 −3 README
View
33 README
@@ -1,13 +1,40 @@
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 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
Please sign in to comment.
Something went wrong with that request. Please try again.