aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-13 03:27:26 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-13 03:27:26 +0000
commit75b8a66638c0acff2fd7761a1e83befc35e5d0ba (patch)
tree5ccd3c3e566ca90fda2dca04d104487ba1803172 /actionpack/lib/action_view/helpers
parentc07c48d10a4b96c83befe25dc27f558bc59cfc9d (diff)
downloadrails-75b8a66638c0acff2fd7761a1e83befc35e5d0ba.tar.gz
rails-75b8a66638c0acff2fd7761a1e83befc35e5d0ba.tar.bz2
rails-75b8a66638c0acff2fd7761a1e83befc35e5d0ba.zip
The mere existance of a rjs file shouldnt cause the layout to disappear. Made it easier to specify a :with on observer_field
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3858 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 7781612180..d49bc94517 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -331,7 +331,11 @@ module ActionView
# <tt>:with</tt>:: A JavaScript expression specifying the
# parameters for the XMLHttpRequest. This defaults
# to 'value', which in the evaluated context
- # refers to the new field value.
+ # refers to the new field value. If you specify a
+ # string without a "=", it'll be extended to mean
+ # the form key that the value should be assigned to.
+ # So :with => "term" gives "'term'=value". If a "=" is
+ # present, no extension will happen.
# <tt>:on</tt>:: Specifies which event handler to observe. By default,
# it's set to "changed" for text fields and areas and
# "click" for radio buttons and checkboxes. With this,
@@ -692,7 +696,12 @@ module ActionView
end
def build_observer(klass, name, options = {})
- options[:with] ||= 'value' if options[:update]
+ if options[:with] && !options[:with].include?("=")
+ options[:with] = "'#{options[:with]}=' + value"
+ else
+ options[:with] ||= 'value' if options[:update]
+ end
+
callback = remote_function(options)
javascript = "new #{klass}('#{name}', "
javascript << "#{options[:frequency]}, " if options[:frequency]