aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/prototype_helper.rb
diff options
context:
space:
mode:
authorSam Stephenson <sam@37signals.com>2006-03-13 02:11:59 +0000
committerSam Stephenson <sam@37signals.com>2006-03-13 02:11:59 +0000
commit3589871de82c12123f62c80b4924d2696412065c (patch)
tree8f420e61f86e6860a63cb9bbcc812962954d359f /actionpack/lib/action_view/helpers/prototype_helper.rb
parent955583aed4668981ee32dadcdc7e3c35e83d3adf (diff)
downloadrails-3589871de82c12123f62c80b4924d2696412065c.tar.gz
rails-3589871de82c12123f62c80b4924d2696412065c.tar.bz2
rails-3589871de82c12123f62c80b4924d2696412065c.zip
Added simple alert() notifications for RJS exceptions when config.action_view.debug_rjs = true. Set debug_rjs = true for the default development environment.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3856 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.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 1f6aa274db..7781612180 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -370,12 +370,12 @@ module ActionView
end
private
- def include_helpers_from_context
- @context.extended_by.each do |mod|
- extend mod unless mod.name =~ /^ActionView::Helpers/
+ def include_helpers_from_context
+ @context.extended_by.each do |mod|
+ extend mod unless mod.name =~ /^ActionView::Helpers/
+ end
+ extend GeneratorMethods
end
- extend GeneratorMethods
- end
# JavaScriptGenerator generates blocks of JavaScript code that allow you
# to change the content and presentation of multiple DOM elements. Use
@@ -425,7 +425,12 @@ module ActionView
# <script> tag.
module GeneratorMethods
def to_s #:nodoc:
- @lines * $/
+ returning javascript = @lines * $/ do
+ if ActionView::Base.debug_rjs
+ javascript.replace "try {\n#{javascript}\n} catch (e) "
+ javascript << "{ alert('RJS error:\\n\\n' + e.toString()); throw e }"
+ end
+ end
end
# Returns a element reference by finding it through +id+ in the DOM. This element can then be
@@ -748,7 +753,7 @@ module ActionView
class JavaScriptElementProxy < JavaScriptProxy #:nodoc:
def initialize(generator, id)
@id = id
- super(generator, "$('#{id}')")
+ super(generator, "$(#{id.to_json})")
end
def replace_html(*options_for_render)
@@ -874,7 +879,7 @@ module ActionView
class JavaScriptElementCollectionProxy < JavaScriptCollectionProxy #:nodoc:\
def initialize(generator, pattern)
- super(generator, "$$('#{pattern}')")
+ super(generator, "$$(#{pattern.to_json})")
end
end
end