aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Huber <sean.huber@cox.net>2008-05-29 10:49:38 -0700
committerPratik Naik <pratiknaik@gmail.com>2008-06-04 13:32:53 +0100
commit30a0ebb3eb9fd4c8e4401bcaa4887eb1ce95defa (patch)
tree2d0a36512d6c956b7e64e0e70c78c4da2181917d
parent82e96eb294ae21528c3e05e91c05c7ee5222afbd (diff)
downloadrails-30a0ebb3eb9fd4c8e4401bcaa4887eb1ce95defa.tar.gz
rails-30a0ebb3eb9fd4c8e4401bcaa4887eb1ce95defa.tar.bz2
rails-30a0ebb3eb9fd4c8e4401bcaa4887eb1ce95defa.zip
Add RJS#page.reload. [#277 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb10
-rw-r--r--actionpack/test/template/prototype_helper_test.rb5
3 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 861597701c..66af5fd745 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*
+* Added page.reload functionality. Resolves #277. [Sean Huber]
+
* Fixed Request#remote_ip to only raise hell if the HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR doesn't match (not just if they're both present) [Mark Imbriaco, Bradford Folkens]
* Allow caches_action to accept a layout option [José Valim]
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 602832e470..5a1012954e 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -868,6 +868,16 @@ module ActionView
record "window.location.href = #{url.inspect}"
end
+ # Reloads the browser's current +location+ using JavaScript
+ #
+ # Examples:
+ #
+ # # Generates: window.location.reload();
+ # page.reload
+ def reload
+ record 'window.location.reload()'
+ end
+
# Calls the JavaScript +function+, optionally with the given +arguments+.
#
# If a block is given, the block will be passed to a new JavaScriptGenerator;
diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb
index 53a250f9d5..b63d8a368c 100644
--- a/actionpack/test/template/prototype_helper_test.rb
+++ b/actionpack/test/template/prototype_helper_test.rb
@@ -347,6 +347,11 @@ class JavaScriptGeneratorTest < PrototypeHelperBaseTest
@generator.redirect_to("http://www.example.com/welcome?a=b&c=d")
end
+ def test_reload
+ assert_equal 'window.location.reload();',
+ @generator.reload
+ end
+
def test_delay
@generator.delay(20) do
@generator.hide('foo')