diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 16:25:11 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 16:25:11 +0000 |
commit | 129a159d1247b2bc9cc791a81ef3485e5b061648 (patch) | |
tree | 1a9f6bffb9336fa5812d7afd18b3b7a5df2f576a | |
parent | c2fb8ca393569105cb25bd79d1bf018c20cce51a (diff) | |
download | rails-129a159d1247b2bc9cc791a81ef3485e5b061648.tar.gz rails-129a159d1247b2bc9cc791a81ef3485e5b061648.tar.bz2 rails-129a159d1247b2bc9cc791a81ef3485e5b061648.zip |
Fixed link_to "somewhere", :post => true to produce valid XHTML by using the parentnode instead of document.body for the instant form (closes #3007) [Bob Silva]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3928 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/url_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 4 |
3 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 5d9c228007..07dc50d398 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed link_to "somewhere", :post => true to produce valid XHTML by using the parentnode instead of document.body for the instant form #3007 [Bob Silva] + * 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 #4268 [jonathan@daikini.com] * Make Mime::Type.parse consider q values (if any) [Jamis Buck] diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index b3dd58370e..1abe1b1220 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -269,7 +269,7 @@ module ActionView end def post_javascript_function - "var f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();" + "var f = document.createElement('form'); this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();" end # Processes the _html_options_ hash, converting the boolean diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 25ab89a584..85ce24b1c2 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -110,14 +110,14 @@ class UrlHelperTest < Test::Unit::TestCase def test_link_tag_using_post_javascript assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"var f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();return false;\">Hello</a>", + "<a href=\"http://www.example.com\" onclick=\"var f = document.createElement('form'); this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();return false;\">Hello</a>", link_to("Hello", "http://www.example.com", :post => true) ) end def test_link_tag_using_post_javascript_and_confirm assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;\">Hello</a>", + "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;\">Hello</a>", link_to("Hello", "http://www.example.com", :post => true, :confirm => "Are you serious?") ) end |