aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-18 16:08:09 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-18 16:08:09 +0000
commit7bfca7e717aca77ab8dcc629c55abe71f2e5e4bd (patch)
tree02edc9bd7b29cf85a17d8cb31664720661c40e6d /actionpack/test
parent8b8a30dd0a58325fe64a9dcd86adc2e7104f1edf (diff)
downloadrails-7bfca7e717aca77ab8dcc629c55abe71f2e5e4bd.tar.gz
rails-7bfca7e717aca77ab8dcc629c55abe71f2e5e4bd.tar.bz2
rails-7bfca7e717aca77ab8dcc629c55abe71f2e5e4bd.zip
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 (closes #4268) [jonathan@daikini.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3926 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/prototype_helper_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb
index e0746f62e6..eb8de1ff40 100644
--- a/actionpack/test/template/prototype_helper_test.rb
+++ b/actionpack/test/template/prototype_helper_test.rb
@@ -108,10 +108,20 @@ class PrototypeHelperTest < Test::Unit::TestCase
observe_field("glass", :frequency => 5.minutes, :url => { :action => "reorder_if_empty" })
end
+ def test_observe_field_using_function_for_callback
+ assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {alert('Element changed')})\n//]]>\n</script>),
+ observe_field("glass", :frequency => 5.minutes, :function => "alert('Element changed')")
+ end
+
def test_observe_form
assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {asynchronous:true, evalScripts:true})})\n//]]>\n</script>),
observe_form("cart", :frequency => 2, :url => { :action => "cart_changed" })
end
+
+ def test_observe_form_using_function_for_callback
+ assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {alert('Form changed')})\n//]]>\n</script>),
+ observe_form("cart", :frequency => 2, :function => "alert('Form changed')")
+ end
def test_update_element_function
assert_equal %($('myelement').innerHTML = 'blub';\n),