Changeset 6930
- Timestamp:
- 06/03/07 14:27:43 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/prototype_helper.rb (modified) (1 diff)
- trunk/actionpack/test/template/prototype_helper_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6923 r6930 1 1 *SVN* 2 3 * Allow JSON-style values for the :with option of observe_field. Closes #8557 [kommen] 2 4 3 5 * Remove RAILS_ROOT from backtrace paths. #8540 [Tim Pope] trunk/actionpack/lib/action_view/helpers/prototype_helper.rb
r6775 r6930 699 699 700 700 def build_observer(klass, name, options = {}) 701 if options[:with] && (options[:with] !~ /[ =(.]/)701 if options[:with] && (options[:with] !~ /[\{=(.]/) 702 702 options[:with] = "'#{options[:with]}=' + value" 703 703 else trunk/actionpack/test/template/prototype_helper_test.rb
r6894 r6930 175 175 end 176 176 177 def test_observe_field_using_with_option 178 expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:'id=' + value})})\n//]]>\n</script>) 179 assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => 'id') 180 assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "'id=' + value") 181 end 182 183 def test_observe_field_using_json_in_with_option 184 expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:{'id':value}})})\n//]]>\n</script>) 185 assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "{'id':value}") 186 end 187 177 188 def test_observe_field_using_function_for_callback 178 189 assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {alert('Element changed')})\n//]]>\n</script>),