aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/prototype_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-04-30 01:17:56 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-04-30 01:17:56 +0000
commitda257eb81ba1eab76ef2c1a256916193858418d4 (patch)
tree3b472ae6730ce177c6a496da0ea2b15ab988942d /actionpack/lib/action_view/helpers/prototype_helper.rb
parent0dc70383097f1212fa7d9b21c57e31cfd4b7204c (diff)
downloadrails-da257eb81ba1eab76ef2c1a256916193858418d4.tar.gz
rails-da257eb81ba1eab76ef2c1a256916193858418d4.tar.bz2
rails-da257eb81ba1eab76ef2c1a256916193858418d4.zip
Added the first part of Simply Helpful to core. The rest is pending a clean integartion of polymorphic urls [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6633 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/prototype_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index ed3f7b7d7f..9fa27d6386 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -384,8 +384,19 @@ module ActionView
# page['blank_slate'] # => $('blank_slate');
# page['blank_slate'].show # => $('blank_slate').show();
# page['blank_slate'].show('first').up # => $('blank_slate').show('first').up();
+ #
+ # You can also pass in a record, which will use ActionController::RecordIdentifier.dom_id to lookup
+ # the correct id:
+ #
+ # page[@post] # => $('post_45')
+ # page[Post.new] # => $('new_post')
def [](id)
- JavaScriptElementProxy.new(self, id)
+ case id
+ when String, Symbol, NilClass
+ JavaScriptElementProxy.new(self, id)
+ else
+ JavaScriptElementProxy.new(self, ActionController::RecordIdentifier.dom_id(id))
+ end
end
# Returns an object whose <tt>#to_json</tt> evaluates to +code+. Use this to pass a literal JavaScript