Changeset 3926
- Timestamp:
- 03/18/06 16:08:09 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/prototype_helper.rb (modified) (2 diffs)
- trunk/actionpack/test/template/prototype_helper_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r3917 r3926 1 1 *SVN* 2 3 * 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 #4268 [jonathan@daikini.com] 2 4 3 5 * Make Mime::Type.parse consider q values (if any) [Jamis Buck] trunk/actionpack/lib/action_view/helpers/prototype_helper.rb
r3858 r3926 316 316 # an Ajax call when its contents have changed. 317 317 # 318 # Required +options+ are :318 # Required +options+ are either of: 319 319 # <tt>:url</tt>:: +url_for+-style options for the action to call 320 320 # when the field has changed. 321 # <tt>:function</tt>:: Instead of making a remote call to a URL, you 322 # can specify a function to be called instead. 321 323 # 322 324 # Additional options are: … … 703 705 end 704 706 705 callback = remote_function(options)707 callback = options[:function] || remote_function(options) 706 708 javascript = "new #{klass}('#{name}', " 707 709 javascript << "#{options[:frequency]}, " if options[:frequency] trunk/actionpack/test/template/prototype_helper_test.rb
r3856 r3926 109 109 end 110 110 111 def test_observe_field_using_function_for_callback 112 assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {alert('Element changed')})\n//]]>\n</script>), 113 observe_field("glass", :frequency => 5.minutes, :function => "alert('Element changed')") 114 end 115 111 116 def test_observe_form 112 117 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>), 113 118 observe_form("cart", :frequency => 2, :url => { :action => "cart_changed" }) 119 end 120 121 def test_observe_form_using_function_for_callback 122 assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {alert('Form changed')})\n//]]>\n</script>), 123 observe_form("cart", :frequency => 2, :function => "alert('Form changed')") 114 124 end 115 125