aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-09-04 20:54:10 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-09-04 20:54:10 +0000
commit1d4d037b0d74fbc3c1cad1c192a6ea7278aff081 (patch)
tree7e2f64c751ddb5d0b2d3a11f2eb7c9cb12af3631 /actionpack/lib/action_view
parentbf8b101dd65eb261644c67fdc0e40bf54b9f2564 (diff)
downloadrails-1d4d037b0d74fbc3c1cad1c192a6ea7278aff081.tar.gz
rails-1d4d037b0d74fbc3c1cad1c192a6ea7278aff081.tar.bz2
rails-1d4d037b0d74fbc3c1cad1c192a6ea7278aff081.zip
Added access to nested attributes in RJS (closes #4548) [richcollins@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5004 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 1b915882c6..1f547d4809 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -777,6 +777,21 @@ module ActionView
super(generator, "$(#{id.to_json})")
end
+ # Allows access of element attributes through +attribute+. Examples:
+ #
+ # page['foo']['style'] # => $('foo').style;
+ # page['foo']['style']['color'] # => $('blank_slate').style.color;
+ # page['foo']['style']['color'] = 'red' # => $('blank_slate').style.color = 'red';
+ # page['foo']['style'].color = 'red' # => $('blank_slate').style.color = 'red';
+ def [](attribute)
+ append_to_function_chain!(attribute)
+ self
+ end
+
+ def []=(variable, value)
+ assign(variable, value)
+ end
+
def replace_html(*options_for_render)
call 'update', @generator.send(:render, *options_for_render)
end