diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index b94f0e2f6e..6bb633ed2d 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,14 @@ *SVN* +* Allow link_to_remote to use any DOM-element as the parent of the form elements to be submitted #2137 [erik@ruby-lang.nl]. Example: + + + + + <%= link_to_remote 'Save', :update => "row023", + :submit => "row023", :url => {:action => 'save_row'} %> + + * Fixed that render :partial would fail when :object was a Hash (due to backwards compatibility issues) #2148 [Sam Stephenson] * Fixed JavascriptHelper#auto_complete_for to only include unique items #2153 [Thomas Fuchs] diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 90b7100dff..3a120bf306 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -116,6 +116,11 @@ module ActionView # :before:: Called before request is initiated. # :after:: Called immediately after request was # initiated and before :loading. + # :submit:: Specifies the DOM element ID that's used + # as the parent of the form elements. By + # default this is the current form, but + # it could just as well be the ID of a + # table row or any other DOM element. def link_to_remote(name, options = {}, html_options = {}) link_to_function(name, remote_function(options), html_options) end @@ -531,6 +536,8 @@ module ActionView if options[:form] js_options['parameters'] = 'Form.serialize(this)' + elsif options[:submit] + js_options['parameters'] = "Form.serialize(document.getElementById('#{options[:submit]}'))" elsif options[:with] js_options['parameters'] = options[:with] end