From eb03ff5bf2adb44d37056bae7df1bce6f4b4d6e3 Mon Sep 17 00:00:00 2001 From: Sean Huber Date: Thu, 29 May 2008 10:49:38 -0700 Subject: [PATCH] Added page.reload functionality --- .../lib/action_view/helpers/prototype_helper.rb | 10 ++++++++++ actionpack/test/template/prototype_helper_test.rb | 5 +++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 602832e..b7c2bc3 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 53a250f..384327e 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') -- 1.5.4.3