From 6a5eeab3cde28f0faf187b681fde4e52a96a1268 Mon Sep 17 00:00:00 2001
From: "Karunakar (Ruby)" <revurikarna@gmail.com>
Date: Sun, 9 Oct 2011 00:03:12 +0530
Subject: Revert "Revert "updated the ajax_on_rails.textile for rails3" because
 of invalid git user"

This reverts commit 5d2ffbb992b4ab875a121761fc0cf14dcaa12033.
---
 railties/guides/source/ajax_on_rails.textile | 69 ++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 4 deletions(-)

(limited to 'railties/guides/source/ajax_on_rails.textile')

diff --git a/railties/guides/source/ajax_on_rails.textile b/railties/guides/source/ajax_on_rails.textile
index 29d4fae888..b5d4fb10f8 100644
--- a/railties/guides/source/ajax_on_rails.textile
+++ b/railties/guides/source/ajax_on_rails.textile
@@ -3,7 +3,7 @@ h2. AJAX on Rails
 This guide covers the built-in Ajax/JavaScript functionality of Rails (and more); it will enable you to create rich and dynamic AJAX applications with ease! We will cover the following topics:
 
 * Quick introduction to AJAX and related technologies
-* Handling JavaScript the Rails way: Rails helpers, Prototype and script.aculo.us
+* Unobtrusive JavaScript helpers with drivers for Prototype, jQuery, and more coming (end of inline JS)
 * Testing JavaScript functionality
 
 endprologue.
@@ -26,13 +26,74 @@ How do 'standard' and AJAX requests differ, why does this matter for understandi
 
 h3. Built-in Rails Helpers
 
-Rails' JavaScript framework of choice is "Prototype":http://www.prototypejs.org. Prototype is a generic-purpose JavaScript framework that aims to ease the development of dynamic web applications by offering DOM manipulation, AJAX and other JavaScript functionality ranging from utility functions to object oriented constructs. It is not specifically written for any language, so Rails provides a set of helpers to enable seamless integration of Prototype with your Rails views.
+Rails 3.1 default javaScript framework of choice is Jquery "http://jquery.com".
+
+jQuery is a new kind of JavaScript Library and jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.
+
+jquery-rails is default gem and it adds Ruby on Rails style restful HTTP verbs to the jQuery library. Instead of sending an actual PUT or DELETE request (many browsers only support GET and POST), jQuery will make a POST request with an additional data parameter called _method set to the proper verb. Ruby on Rails can then act accordingly.
+
+Jquery helpers you can access defaultly - typically in your master layout, application.html.erb - like so:
+
+<ruby>
+javascript_include_tag :defaults
+</ruby>
+
+jquery-rails is default in Gemfile.
+
+<ruby>
+javascript_include_tag :defaults
+</ruby>
+
+All the remote_<method< helpers has been removed. To make them working with AJAX, simply pass the :remote => true option to the original non-remote method
+
+==== Examples
+<ruby>
+ button_to "New", :action => "new", :form_class => "new-thing"
+</ruby>
+# => "<form method="post" action="/controller/new" class="new-thing">
+#      <div><input value="New" type="submit" /></div>
+#    </form>"
 
-To get access to these helpers, all you have to do is to include the prototype framework in your pages - typically in your master layout, application.html.erb - like so:
 
 <ruby>
-javascript_include_tag 'prototype'
+ button_to "Create", :action => "create", :remote => true, :form => { "data-type" => "json" }
 </ruby>
+# => "<form method="post" action="/images/create" class="button_to" data-remote="true" data-type="json">
+#      <div><input value="Create" type="submit" /></div>
+#    </form>"
+
+
+<ruby>
+
+button_to "Delete Image", { :action => "delete", :id => @image.id },
+             :confirm => "Are you sure?", :method => :delete
+</ruby>
+
+# => "<form method="post" action="/images/delete/1" class="button_to">
+#      <div>
+#        <input type="hidden" name="_method" value="delete" />
+#        <input data-confirm='Are you sure?' value="Delete" type="submit" />
+#      </div>
+#    </form>"
+
+
+<ruby> button_to('Destroy', 'http://www.example.com', :confirm => 'Are you sure?',
+          :method => "delete", :remote => true, :disable_with => 'loading...')
+</ruby>
+# => "<form class='button_to' method='post' action='http://www.example.com' data-remote='true'>
+#       <div>
+#         <input name='_method' value='delete' type='hidden' />
+#         <input value='Destroy' type='submit' disable_with='loading...' data-confirm='Are you sure?' />
+#       </div>
+#     </form>"
+
+TODO: Write more Jquery helpers here.
+
+You can also specify the prototype to use instead of jquery or any other libraries
+
+rails new app_name -j prototype
+
+Prototype is a generic-purpose JavaScript framework that aims to ease the development of dynamic web applications by offering DOM manipulation, AJAX and other JavaScript functionality ranging from utility functions to object oriented constructs. It is not specifically written for any language, so Rails provides a set of helpers to enable seamless integration of Prototype with your Rails views.
 
 You are ready to add some AJAX love to your Rails app!
 
-- 
cgit v1.2.3


From 43baad78f758fe16485202643721a07852b25376 Mon Sep 17 00:00:00 2001
From: "Karunakar (Ruby)" <revurikarna@gmail.com>
Date: Sun, 9 Oct 2011 12:46:25 +0530
Subject: improving the docs for ajax_on_rails

---
 railties/guides/source/ajax_on_rails.textile | 35 +++++++++++++++++-----------
 1 file changed, 22 insertions(+), 13 deletions(-)

(limited to 'railties/guides/source/ajax_on_rails.textile')

diff --git a/railties/guides/source/ajax_on_rails.textile b/railties/guides/source/ajax_on_rails.textile
index b5d4fb10f8..9f5afc87de 100644
--- a/railties/guides/source/ajax_on_rails.textile
+++ b/railties/guides/source/ajax_on_rails.textile
@@ -44,23 +44,30 @@ jquery-rails is default in Gemfile.
 javascript_include_tag :defaults
 </ruby>
 
+h4. Examples
+
 All the remote_<method< helpers has been removed. To make them working with AJAX, simply pass the :remote => true option to the original non-remote method
 
-==== Examples
 <ruby>
  button_to "New", :action => "new", :form_class => "new-thing"
 </ruby>
-# => "<form method="post" action="/controller/new" class="new-thing">
-#      <div><input value="New" type="submit" /></div>
-#    </form>"
+
+will produce
+
+<form method="post" action="/controller/new" class="new-thing">
+  <div><input value="New" type="submit" /></div>
+</form>
 
 
 <ruby>
  button_to "Create", :action => "create", :remote => true, :form => { "data-type" => "json" }
 </ruby>
-# => "<form method="post" action="/images/create" class="button_to" data-remote="true" data-type="json">
-#      <div><input value="Create" type="submit" /></div>
-#    </form>"
+
+will produce
+
+<form method="post" action="/images/create" class="button_to" data-remote="true" data-type="json">
+  <div><input value="Create" type="submit" /></div>
+</form>
 
 
 <ruby>
@@ -69,12 +76,14 @@ button_to "Delete Image", { :action => "delete", :id => @image.id },
              :confirm => "Are you sure?", :method => :delete
 </ruby>
 
-# => "<form method="post" action="/images/delete/1" class="button_to">
-#      <div>
-#        <input type="hidden" name="_method" value="delete" />
-#        <input data-confirm='Are you sure?' value="Delete" type="submit" />
-#      </div>
-#    </form>"
+will produce
+
+<form method="post" action="/images/delete/1" class="button_to">
+  <div>
+    <input type="hidden" name="_method" value="delete" />
+    <input data-confirm='Are you sure?' value="Delete" type="submit" />
+ </div>
+</form>
 
 
 <ruby> button_to('Destroy', 'http://www.example.com', :confirm => 'Are you sure?',
-- 
cgit v1.2.3


From 3a72c01be2add83c76e6180d60a520491484c01e Mon Sep 17 00:00:00 2001
From: Vijay Dev <vijaydev.cse@gmail.com>
Date: Sun, 9 Oct 2011 19:58:14 +0530
Subject: Corrections to the ajax guide recent changes. This guide is very
 outdated and will need a lot of changes to make it useful for Rails 3+

---
 railties/guides/source/ajax_on_rails.textile | 58 +++++++++++++---------------
 1 file changed, 26 insertions(+), 32 deletions(-)

(limited to 'railties/guides/source/ajax_on_rails.textile')

diff --git a/railties/guides/source/ajax_on_rails.textile b/railties/guides/source/ajax_on_rails.textile
index 9f5afc87de..3a0ccfe9b2 100644
--- a/railties/guides/source/ajax_on_rails.textile
+++ b/railties/guides/source/ajax_on_rails.textile
@@ -3,7 +3,7 @@ h2. AJAX on Rails
 This guide covers the built-in Ajax/JavaScript functionality of Rails (and more); it will enable you to create rich and dynamic AJAX applications with ease! We will cover the following topics:
 
 * Quick introduction to AJAX and related technologies
-* Unobtrusive JavaScript helpers with drivers for Prototype, jQuery, and more coming (end of inline JS)
+* Unobtrusive JavaScript helpers with drivers for Prototype, jQuery etc
 * Testing JavaScript functionality
 
 endprologue.
@@ -26,19 +26,7 @@ How do 'standard' and AJAX requests differ, why does this matter for understandi
 
 h3. Built-in Rails Helpers
 
-Rails 3.1 default javaScript framework of choice is Jquery "http://jquery.com".
-
-jQuery is a new kind of JavaScript Library and jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.
-
-jquery-rails is default gem and it adds Ruby on Rails style restful HTTP verbs to the jQuery library. Instead of sending an actual PUT or DELETE request (many browsers only support GET and POST), jQuery will make a POST request with an additional data parameter called _method set to the proper verb. Ruby on Rails can then act accordingly.
-
-Jquery helpers you can access defaultly - typically in your master layout, application.html.erb - like so:
-
-<ruby>
-javascript_include_tag :defaults
-</ruby>
-
-jquery-rails is default in Gemfile.
+Rails 3.1 ships with "jQuery":http://jquery.com as the default JavaScript library. The Gemfile contains <tt>gem 'jquery-rails'</tt> which makes the jQuery files available to the application automatically. This can be accessed as:
 
 <ruby>
 javascript_include_tag :defaults
@@ -46,63 +34,69 @@ javascript_include_tag :defaults
 
 h4. Examples
 
-All the remote_<method< helpers has been removed. To make them working with AJAX, simply pass the :remote => true option to the original non-remote method
+All the remote_method helpers has been removed. To make them working with AJAX, simply pass the <tt>:remote => true</tt> option to the original non-remote method.
 
 <ruby>
- button_to "New", :action => "new", :form_class => "new-thing"
+button_to "New", :action => "new", :form_class => "new-thing"
 </ruby>
 
 will produce
 
+<html>
 <form method="post" action="/controller/new" class="new-thing">
   <div><input value="New" type="submit" /></div>
 </form>
-
+</html>
 
 <ruby>
- button_to "Create", :action => "create", :remote => true, :form => { "data-type" => "json" }
+button_to "Create", :action => "create", :remote => true, :form => { "data-type" => "json" }
 </ruby>
 
 will produce
 
+<html>
 <form method="post" action="/images/create" class="button_to" data-remote="true" data-type="json">
   <div><input value="Create" type="submit" /></div>
 </form>
-
+</html>
 
 <ruby>
-
 button_to "Delete Image", { :action => "delete", :id => @image.id },
              :confirm => "Are you sure?", :method => :delete
 </ruby>
 
 will produce
 
+<html>
 <form method="post" action="/images/delete/1" class="button_to">
   <div>
     <input type="hidden" name="_method" value="delete" />
     <input data-confirm='Are you sure?' value="Delete" type="submit" />
  </div>
 </form>
+</html>
 
-
-<ruby> button_to('Destroy', 'http://www.example.com', :confirm => 'Are you sure?',
+<ruby>
+button_to('Destroy', 'http://www.example.com', :confirm => 'Are you sure?',
           :method => "delete", :remote => true, :disable_with => 'loading...')
 </ruby>
-# => "<form class='button_to' method='post' action='http://www.example.com' data-remote='true'>
-#       <div>
-#         <input name='_method' value='delete' type='hidden' />
-#         <input value='Destroy' type='submit' disable_with='loading...' data-confirm='Are you sure?' />
-#       </div>
-#     </form>"
 
-TODO: Write more Jquery helpers here.
+will produce
 
-You can also specify the prototype to use instead of jquery or any other libraries
+<html>
+<form class='button_to' method='post' action='http://www.example.com' data-remote='true'>
+  <div>
+    <input name='_method' value='delete' type='hidden' />
+    <input value='Destroy' type='submit' disable_with='loading...' data-confirm='Are you sure?' />
+  </div>
+</form>
+</html>
 
-rails new app_name -j prototype
+You can also choose to use Prototype instead of jQuery and specify the option using +-j+ switch while generating the application.
 
-Prototype is a generic-purpose JavaScript framework that aims to ease the development of dynamic web applications by offering DOM manipulation, AJAX and other JavaScript functionality ranging from utility functions to object oriented constructs. It is not specifically written for any language, so Rails provides a set of helpers to enable seamless integration of Prototype with your Rails views.
+<shell>
+rails new app_name -j prototype
+</shell>
 
 You are ready to add some AJAX love to your Rails app!
 
-- 
cgit v1.2.3

