From 1962217e42319d70250d017397849990c5b981e0 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 29 May 2011 18:35:42 +0530 Subject: removed references to old remote_* helpers; add info about 3.1 adding multipart option to a form with file_field automatically --- .../guides/source/action_view_overview.textile | 107 +-------------------- 1 file changed, 5 insertions(+), 102 deletions(-) (limited to 'railties/guides') diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index b064851312..8c6a82d50c 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -1037,7 +1037,7 @@ Sample usage (selecting the associated Author for an instance of Post, +@post+): collection_select(:post, :author_id, Author.all, :id, :name_with_initial, {:prompt => true}) -If @post.author_id is already 1, this would return: +If @post.author_id is 1, this would return: @@ -1189,7 +1187,7 @@ h5. file_field_tag Creates a file upload field. -If you are using file uploads then you will also need to set the multipart option for the form tag: +Prior to Rails 3.1, if you are using file uploads, then you will need to set the multipart option for the form tag. Rails 3.1+ does this automatically. <%= form_tag { :action => "post" }, { :multipart => true } do %> @@ -1400,102 +1398,6 @@ number_with_precision(111.2345) # => 111.235 number_with_precision(111.2345, 2) # => 111.23 -h5. evaluate_remote_response - -Returns +eval(request.responseText)+ which is the JavaScript function that form_remote_tag can call in +:complete+ to evaluate a multiple update return document using +update_element_function+ calls. - -h5. form_remote_tag - -Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular reloading POST arrangement. Even though it‘s using JavaScript to serialize the form elements, the form submission will work just like a regular submission as viewed by the receiving side. - -For example, this: - - -form_remote_tag :html => { :action => url_for(:controller => "some", :action => "place") } - - -would generate the following: - - -
- - -h5. link_to_remote - -Returns a link to a remote action that's called in the background using XMLHttpRequest. You can generate a link that uses AJAX in the general case, while degrading gracefully to plain link behavior in the absence of JavaScript. For example: - - -link_to_remote "Delete this post", - { :update => "posts", :url => { :action => "destroy", :id => post.id } }, - :href => url_for(:action => "destroy", :id => post.id) - - -h5. observe_field - -Observes the field specified and calls a callback when its contents have changed. - - -observe_field("my_field", :function => "alert('Field changed')") - - -h5. observe_form - -Observes the form specified and calls a callback when its contents have changed. The options for observe_form are the same as the options for observe_field. - - -observe_field("my_form", :function => "alert('Form changed')") - - -h5. periodically_call_remote - -Periodically calls the specified url as often as specified. Usually used to update a specified div with the results of the remote call. The following example will call update every 20 seconds and update the news_block div: - - -periodically_call_remote(:url => 'update', :frequency => '20', :update => 'news_block') -# => PeriodicalExecuter(function() {new Ajax.Updater('news_block', 'update', {asynchronous:true, evalScripts:true})}, 20) - - -h5. remote_form_for - -Creates a form that will submit using XMLHttpRequest in the background instead of the regular reloading POST arrangement and a scope around a specific resource that is used as a base for questioning about values for the fields. - - -<%= remote_form_for(@post) do |f| %> - ... -<% end %> - - -h5. remote_function - -Returns the JavaScript needed for a remote function. Takes the same arguments as +link_to_remote+. - - - -# => - - h3. Localized Views Action View has the ability render different templates depending on the current locale. @@ -1520,6 +1422,7 @@ You can read more about the Rails Internationalization (I18n) API "here":i18n.ht h3. Changelog +* May 29, 2011: Removed references to remote_* helpers - Vijay Dev * April 16, 2011: Added 'Using Action View with Rails', 'Templates' and 'Partials' sections. "Sebastian Martinez":http://wyeworks.com * September 3, 2009: Continuing work by Trevor Turk, leveraging the Action Pack docs and "What's new in Edge Rails":http://ryandaigle.com/articles/2007/8/3/what-s-new-in-edge-rails-partials-get-layouts * April 5, 2009: Starting work by Trevor Turk, leveraging Mike Gunderloy's docs -- cgit v1.2.3