Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

The mere existance of a rjs file shouldnt cause the layout to disappe…

…ar. 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
  • Loading branch information...
commit 75b8a66638c0acff2fd7761a1e83befc35e5d0ba 1 parent c07c48d
@dhh dhh authored
View
4 actionpack/lib/action_controller/base.rb
@@ -1003,7 +1003,9 @@ def template_public?(template_name = default_template_name)
end
def template_exempt_from_layout?(template_name = default_template_name)
- @template.javascript_template_exists?(template_name)
+ @template.pick_template_extension(template_name).to_sym == :rjs
+ rescue
+ false
end
def assert_existance_of_template_file(template_name)
View
13 actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -331,7 +331,11 @@ def remote_function(options)
# <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 @@ def method_option_to_s(method)
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]
Please sign in to comment.
Something went wrong with that request. Please try again.