aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-18 16:08:09 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-18 16:08:09 +0000
commit7bfca7e717aca77ab8dcc629c55abe71f2e5e4bd (patch)
tree02edc9bd7b29cf85a17d8cb31664720661c40e6d /actionpack/lib
parent8b8a30dd0a58325fe64a9dcd86adc2e7104f1edf (diff)
downloadrails-7bfca7e717aca77ab8dcc629c55abe71f2e5e4bd.tar.gz
rails-7bfca7e717aca77ab8dcc629c55abe71f2e5e4bd.tar.bz2
rails-7bfca7e717aca77ab8dcc629c55abe71f2e5e4bd.zip
Added :function option to PrototypeHelper#observe_field/observe_form that allows you to call a function instead of submitting an ajax call as the trigger (closes #4268) [jonathan@daikini.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3926 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index d49bc94517..35a671c081 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -315,9 +315,11 @@ module ActionView
# Observes the field with the DOM ID specified by +field_id+ and makes
# an Ajax call when its contents have changed.
#
- # Required +options+ are:
+ # Required +options+ are either of:
# <tt>:url</tt>:: +url_for+-style options for the action to call
# when the field has changed.
+ # <tt>:function</tt>:: Instead of making a remote call to a URL, you
+ # can specify a function to be called instead.
#
# Additional options are:
# <tt>:frequency</tt>:: The frequency (in seconds) at which changes to
@@ -702,7 +704,7 @@ module ActionView
options[:with] ||= 'value' if options[:update]
end
- callback = remote_function(options)
+ callback = options[:function] || remote_function(options)
javascript = "new #{klass}('#{name}', "
javascript << "#{options[:frequency]}, " if options[:frequency]
javascript << "function(element, value) {"