aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2007-12-05 21:33:10 +0000
committerMarcel Molina <marcel@vernix.org>2007-12-05 21:33:10 +0000
commit7e608af9ffd4fd62d6dca9fd2d4a31d6397f3b4d (patch)
tree7fa5dc08208798023f6b2b8edf66d1e4feb86447
parent9ffb6328ea97eb7f5cffb13f902b59122a499575 (diff)
downloadrails-7e608af9ffd4fd62d6dca9fd2d4a31d6397f3b4d.tar.gz
rails-7e608af9ffd4fd62d6dca9fd2d4a31d6397f3b4d.tar.bz2
rails-7e608af9ffd4fd62d6dca9fd2d4a31d6397f3b4d.zip
Add documentation examples to prototype helper. Closes #7211 [manfred]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8308 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb25
2 files changed, 25 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 2bcbe27011..12e02ba125 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Add documentation examples to prototype helper. Closes #7211 [manfred]
+
* Enhance documentation coverage for fragment caching. Closes #7315 [bscofield]
* Fix typo in number helper docs. Closes #7582 [josh]
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 726b790a3d..fa701f50b8 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -531,8 +531,23 @@ module ActionView
# you can specify it instead to be "blur" or "focus" or
# any other event.
#
- # Additionally, you may specify any of the options documented in
- # link_to_remote.
+ # Additionally, you may specify any of the options documented in the
+ # <em>Common options</em> section at the top of this document.
+ #
+ # Example:
+ #
+ # # Sends params: {:title => 'Title of the book'} when the book_title input
+ # # field is changed.
+ # observe_field 'book_title',
+ # :url => 'http://example.com/books/edit/1',
+ # :with => 'title'
+ #
+ # # Sends params: {:book_title => 'Title of the book'} when the focus leaves
+ # # the input field.
+ # observe_field 'book_title',
+ # :url => 'http://example.com/books/edit/1',
+ # :on => 'blur'
+ #
def observe_field(field_id, options = {})
if options[:frequency] && options[:frequency] > 0
build_observer('Form.Element.Observer', field_id, options)
@@ -967,6 +982,12 @@ module ActionView
# Yields a JavaScriptGenerator and returns the generated JavaScript code.
# Use this to update multiple elements on a page in an Ajax response.
# See JavaScriptGenerator for more information.
+ #
+ # Example:
+ #
+ # update_page do |page|
+ # page.hide 'spinner'
+ # end
def update_page(&block)
JavaScriptGenerator.new(@template, &block).to_s
end