From f20f230a588369a7876d5a7bc03efee3c3028200 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sat, 16 Jun 2012 17:52:26 -0500 Subject: unnecessary reference to link_to_remote method in rails 4.0 [ci skip] --- guides/source/ajax_on_rails.textile | 53 +++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'guides') 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 gem 'jquery-rails' 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 gem 'jquery-rails' which makes the jQuery files +available to the application automatically. This can be accessed as: 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 :remote => true option to the original non-remote method. +To make them working with AJAX, simply pass the remote: true option to +the original non-remote method. -button_to "New", :action => "new", :form_class => "new-thing" +button_to 'New', action: 'new', form_class: 'new-thing' will produce @@ -61,7 +68,7 @@ will produce -button_to "Create", :action => "create", :remote => true, :form => { "data-type" => "json" } +button_to 'Create', action: 'create', remote: true, form: { 'data-type' => 'json' } will produce @@ -73,8 +80,8 @@ will produce -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 will produce @@ -89,8 +96,8 @@ will produce -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...') will produce -- cgit v1.2.3