aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-06-16 17:52:26 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-06-16 17:52:43 -0500
commitf20f230a588369a7876d5a7bc03efee3c3028200 (patch)
tree92704998e14913b974f93323e3e1d8fb77447469 /guides
parent7ed38907fd9e8a4f4a3fe9b33b1902acfafaef24 (diff)
downloadrails-f20f230a588369a7876d5a7bc03efee3c3028200.tar.gz
rails-f20f230a588369a7876d5a7bc03efee3c3028200.tar.bz2
rails-f20f230a588369a7876d5a7bc03efee3c3028200.zip
unnecessary reference to link_to_remote method in rails 4.0 [ci skip]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/ajax_on_rails.textile53
1 files changed, 30 insertions, 23 deletions
diff --git a/guides/source/ajax_on_rails.textile b/guides/source/ajax_on_rails.textile
index 301b6060da..224c318c99 100644
--- a/guides/source/ajax_on_rails.textile
+++ b/guides/source/ajax_on_rails.textile
@@ -1,6 +1,8 @@
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:
+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 etc
@@ -10,23 +12,25 @@ endprologue.
h3. Hello AJAX - a Quick Intro
-AJAX is about updating parts of a web page, without reloading the page. An AJAX call happens as a
-response to an event, like when the page finished loading or when a user clicks on an element. For
-example, let say you click on a link, which would usually take you to a new page, but instead of
-doing that, an asynchronous HTTP request is made and the response is evaluated with javascript.
-That way the page is not reloaded, and new information can be dynamically included in the page.
-The way that happens is by inserting, removing or changing parts of the DOM. The DOM, or
-Document Object Model, is a convention to represent the HTML document as a set of nodes that contain
-other nodes. For example a list of names is represented as a @ul@ element node containing several
-@li@ element nodess. An AJAX call can be made to obtain a new list item to include, and append it
-inside a @li@ node to the @ul@ node.
+AJAX is about updating parts of a web page, without reloading the page. An AJAX
+call happens as a response to an event, like when the page finished loading or
+when a user clicks on an element. For example, let say you click on a link, which
+would usually take you to a new page, but instead of doing that, an asynchronous
+HTTP request is made and the response is evaluated with javascript. That way the
+page is not reloaded, and new information can be dynamically included in the page.
+The way that happens is by inserting, removing or changing parts of the DOM. The
+DOM, or Document Object Model, is a convention to represent the HTML document as
+a set of nodes that contain other nodes. For example a list of names is represented
+as a @ul@ element node containing several @li@ element nodess. An AJAX call can
+be made to obtain a new list item to include, and append it inside a @li@ node to
+the @ul@ node.
h4. Asynchronous JavaScript + XML
-AJAX means Asynchronous JavaScript + XML. Asynchronous means that the page is not reloaded, the
-request made is separate from the regular page request. Javascript is used to evaluate the response
-and the XML part is a bit misleading as XML is not required, you respond to the HTTP request with
-JSON or regular HTML as well.
+AJAX means Asynchronous JavaScript + XML. Asynchronous means that the page is not
+reloaded, the request made is separate from the regular page request. Javascript
+is used to evaluate the response and the XML part is a bit misleading as XML is
+not required, you respond to the HTTP request with JSON or regular HTML as well.
h4. The DOM
@@ -38,7 +42,9 @@ How do 'standard' and AJAX requests differ, why does this matter for understandi
h3. Built-in Rails Helpers
-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:
+Rails 4.0 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,10 +52,11 @@ javascript_include_tag :defaults
h4. Examples
-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.
+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
@@ -61,7 +68,7 @@ will produce
</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
@@ -73,8 +80,8 @@ will produce
</html>
<ruby>
-button_to "Delete Image", { :action => "delete", :id => @image.id },
- :confirm => "Are you sure?", :method => :delete
+button_to 'Delete Image', { action: 'delete', id: @image.id },
+ confirm: 'Are you sure?', method: :delete
</ruby>
will produce
@@ -89,8 +96,8 @@ will produce
</html>
<ruby>
-button_to('Destroy', 'http://www.example.com', :confirm => 'Are you sure?',
- :method => "delete", :remote => true, 'data-disable-with' => 'loading...')
+button_to 'Destroy', 'http://www.example.com', confirm: 'Are you sure?',
+ method: 'delete', remote: true, 'data-disable-with' => 'loading...')
</ruby>
will produce