From 8ff92e243568a6ae72e88f48a7ae15dffaf81e57 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 9 Oct 2006 00:50:11 +0000 Subject: Added an html_options hash parameter to javascript_tag() and update_page_tag() helpers #6311 [tzaharia] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5245 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 10 ++++++++++ actionpack/lib/action_view/helpers/javascript_helper.rb | 7 +++++-- actionpack/lib/action_view/helpers/prototype_helper.rb | 7 +++++-- actionpack/test/template/prototype_helper_test.rb | 6 ++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index a9bd209f15..41f71cc68c 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,15 @@ *SVN* +* Added an html_options hash parameter to javascript_tag() and update_page_tag() helpers #6311 [tzaharia]. Example: + + update_page_tag :defer => 'true' { |page| ... } + + Gives: + + + + Which is needed for dealing with the IE6 DOM when it's not yet fully loaded. + * Fixed that rescue template path shouldn't be hardcoded, then it's easier to hook in your own #6295 [mnaberez] * Fixed escaping of backslashes in JavaScriptHelper#escape_javascript #6302 [sven@c3d2.de] diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 039a2f1810..7bce6b91eb 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -162,8 +162,11 @@ module ActionView # alert('All is good') # //]]> # - def javascript_tag(content) - content_tag("script", javascript_cdata_section(content), :type => "text/javascript") + # + # +html_options+ may be a hash of attributes for the + def javascript_tag(content, html_options = {}) + content_tag("script", javascript_cdata_section(content), html_options.merge(:type => "text/javascript")) end def javascript_cdata_section(content) #:nodoc: diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 60dc2e8bb4..f1b956cf12 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -684,8 +684,11 @@ module ActionView # Works like update_page but wraps the generated JavaScript in a