diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2012-03-07 06:51:33 -0800 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2012-03-07 06:51:33 -0800 |
commit | 6588560c616882a3fff7cad5108f61448944e77c (patch) | |
tree | 51b1d8e30844b1faf1d324117c9290f04621d754 /railties/guides | |
parent | e64dbb5b364442b2ca491fad30ce09268937eff1 (diff) | |
parent | 9ab7620eb55d00515f0fef2bd9d15e1cd511e716 (diff) | |
download | rails-6588560c616882a3fff7cad5108f61448944e77c.tar.gz rails-6588560c616882a3fff7cad5108f61448944e77c.tar.bz2 rails-6588560c616882a3fff7cad5108f61448944e77c.zip |
Merge pull request #88 from kevingriffin/master
Correct "its" usage for "AJAX on Rails" page
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/ajax_on_rails.textile | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/railties/guides/source/ajax_on_rails.textile b/railties/guides/source/ajax_on_rails.textile index 5913a472fd..cda9c64460 100644 --- a/railties/guides/source/ajax_on_rails.textile +++ b/railties/guides/source/ajax_on_rails.textile @@ -134,7 +134,7 @@ If the server returns 200, the output of the above example is equivalent to our ** *position* By default (i.e. when not specifying this option, like in the examples before) the response is injected into the element with the specified DOM id, replacing the original content of the element (if there was any). You might want to alter this behavior by keeping the original content - the only question is where to place the new content? This can specified by the +position+ parameter, with four possibilities: *** +:before+ Inserts the response text just before the target element. More precisely, it creates a text node from the response and inserts it as the left sibling of the target element. *** +:after+ Similar behavior to +:before+, but in this case the response is inserted after the target element. -*** +:top+ Inserts the text into the target element, before it's original content. If the target element was empty, this is equivalent with not specifying +:position+ at all. +*** +:top+ Inserts the text into the target element, before its original content. If the target element was empty, this is equivalent with not specifying +:position+ at all. *** +:bottom+ The counterpart of +:top+: the response is inserted after the target element's original content. A typical example of using +:bottom+ is inserting a new <li> element into an existing list: @@ -174,7 +174,7 @@ link_to_remote "Update record", This generates a remote link which adds 2 parameters to the standard URL generated by Rails, taken from the page (contained in the elements matched by the 'status' and 'completed' DOM id). -** *Callbacks* Since an AJAX call is typically asynchronous, as it's name suggests (this is not a rule, and you can fire a synchronous request - see the last option, +:type+) your only way of communicating with a request once it is fired is via specifying callbacks. There are six options at your disposal (in fact 508, counting all possible response types, but these six are the most frequent and therefore specified by a constant): +** *Callbacks* Since an AJAX call is typically asynchronous, as its name suggests (this is not a rule, and you can fire a synchronous request - see the last option, +:type+) your only way of communicating with a request once it is fired is via specifying callbacks. There are six options at your disposal (in fact 508, counting all possible response types, but these six are the most frequent and therefore specified by a constant): *** +:loading:+ => +code+ The request is in the process of receiving the data, but the transfer is not completed yet. *** +:loaded:+ => +code+ The transfer is completed, but the data is not processed and returned yet *** +:interactive:+ => +code+ One step after +:loaded+: The data is fully received and being processed @@ -203,7 +203,7 @@ link_to_remote "Add new item", ** *:type* If you want to fire a synchronous request for some obscure reason (blocking the browser while the request is processed and doesn't return a status code), you can use the +:type+ option with the value of +:synchronous+. * Finally, using the +html_options+ parameter you can add HTML attributes to the generated tag. It works like the same parameter of the +link_to+ helper. There are interesting side effects for the +href+ and +onclick+ parameters though: ** If you specify the +href+ parameter, the AJAX link will degrade gracefully, i.e. the link will point to the URL even if JavaScript is disabled in the client browser -** +link_to_remote+ gains it's AJAX behavior by specifying the remote call in the onclick handler of the link. If you supply +html_options[:onclick]+ you override the default behavior, so use this with care! +** +link_to_remote+ gains its AJAX behavior by specifying the remote call in the onclick handler of the link. If you supply +html_options[:onclick]+ you override the default behavior, so use this with care! We are finished with +link_to_remote+. I know this is quite a lot to digest for one helper function, but remember, these options are common for all the rest of the Rails view helpers, so we will take a look at the differences / additional parameters in the next sections. @@ -211,8 +211,8 @@ h4. AJAX Forms There are three different ways of adding AJAX forms to your view using Rails Prototype helpers. They are slightly different, but striving for the same goal: instead of submitting the form using the standard HTTP request/response cycle, it is submitted asynchronously, thus not reloading the page. These methods are the following: -* +remote_form_for+ (and it's alias +form_remote_for+) is tied to Rails most tightly of the three since it takes a resource, model or array of resources (in case of a nested resource) as a parameter. -* +form_remote_tag+ AJAXifies the form by serializing and sending it's data in the background +* +remote_form_for+ (and its alias +form_remote_for+) is tied to Rails most tightly of the three since it takes a resource, model or array of resources (in case of a nested resource) as a parameter. +* +form_remote_tag+ AJAXifies the form by serializing and sending its data in the background * +submit_to_remote+ and +button_to_remote+ is more rarely used than the previous two. Rather than creating an AJAX form, you add a button/input Let's see them in action one by one! |