diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-01-30 15:42:30 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-01-30 15:42:30 -0600 |
commit | 9c2c307ee48b91177c3e1cb8831afe4f972d19eb (patch) | |
tree | 82aadaceabadbe18546b9f62976ff385711546f9 /actionpack/lib | |
parent | 779094a6024c762b3dfb60db7efb1d5d7f0c4ddc (diff) | |
download | rails-9c2c307ee48b91177c3e1cb8831afe4f972d19eb.tar.gz rails-9c2c307ee48b91177c3e1cb8831afe4f972d19eb.tar.bz2 rails-9c2c307ee48b91177c3e1cb8831afe4f972d19eb.zip |
Move form_remote_tag and remote_form_for into prototype_legacy_helper
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/prototype_helper.rb | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 818412c345..1fa2fed460 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -102,115 +102,6 @@ module ActionView :form, :with, :update, :script, :type ]).merge(CALLBACKS) end - # Returns a form tag that will submit using XMLHttpRequest in the - # background instead of the regular reloading POST arrangement. Even - # though it's using JavaScript to serialize the form elements, the form - # submission will work just like a regular submission as viewed by the - # receiving side (all elements available in <tt>params</tt>). The options for - # specifying the target with <tt>:url</tt> and defining callbacks is the same as - # +link_to_remote+. - # - # A "fall-through" target for browsers that doesn't do JavaScript can be - # specified with the <tt>:action</tt>/<tt>:method</tt> options on <tt>:html</tt>. - # - # Example: - # # Generates: - # # <form action="/some/place" method="post" onsubmit="new Ajax.Request('', - # # {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"> - # form_remote_tag :html => { :action => - # url_for(:controller => "some", :action => "place") } - # - # The Hash passed to the <tt>:html</tt> key is equivalent to the options (2nd) - # argument in the FormTagHelper.form_tag method. - # - # By default the fall-through action is the same as the one specified in - # the <tt>:url</tt> (and the default method is <tt>:post</tt>). - # - # form_remote_tag also takes a block, like form_tag: - # # Generates: - # # <form action="/" method="post" onsubmit="new Ajax.Request('/', - # # {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); - # # return false;"> <div><input name="commit" type="submit" value="Save" /></div> - # # </form> - # <% form_remote_tag :url => '/posts' do -%> - # <div><%= submit_tag 'Save' %></div> - # <% end -%> - def form_remote_tag(options = {}, &block) - options[:form] = true - - options[:html] ||= {} - options[:html][:onsubmit] = - (options[:html][:onsubmit] ? options[:html][:onsubmit] + "; " : "") + - "#{remote_function(options)}; return false;" - - form_tag(options[:html].delete(:action) || url_for(options[:url]), options[:html], &block) - end - - # Creates a form that will submit using XMLHttpRequest in the background - # instead of the regular reloading POST arrangement and a scope around a - # specific resource that is used as a base for questioning about - # values for the fields. - # - # === Resource - # - # Example: - # <% remote_form_for(@post) do |f| %> - # ... - # <% end %> - # - # This will expand to be the same as: - # - # <% remote_form_for :post, @post, :url => post_path(@post), :html => { :method => :put, :class => "edit_post", :id => "edit_post_45" } do |f| %> - # ... - # <% end %> - # - # === Nested Resource - # - # Example: - # <% remote_form_for([@post, @comment]) do |f| %> - # ... - # <% end %> - # - # This will expand to be the same as: - # - # <% remote_form_for :comment, @comment, :url => post_comment_path(@post, @comment), :html => { :method => :put, :class => "edit_comment", :id => "edit_comment_45" } do |f| %> - # ... - # <% end %> - # - # If you don't need to attach a form to a resource, then check out form_remote_tag. - # - # See FormHelper#form_for for additional semantics. - def remote_form_for(record_or_name_or_array, *args, &proc) - options = args.extract_options! - - case record_or_name_or_array - when String, Symbol - object_name = record_or_name_or_array - when Array - object = record_or_name_or_array.last - object_name = ActionController::RecordIdentifier.singular_class_name(object) - apply_form_for_options!(record_or_name_or_array, options) - args.unshift object - else - object = record_or_name_or_array - object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name_or_array) - apply_form_for_options!(object, options) - args.unshift object - end - - concat(form_remote_tag(options)) - fields_for(object_name, *(args << options), &proc) - concat('</form>'.html_safe!) - end - alias_method :form_remote_for, :remote_form_for - - # Returns '<tt>eval(request.responseText)</tt>' which is the JavaScript function - # that +form_remote_tag+ can call in <tt>:complete</tt> to evaluate a multiple - # update return document using +update_element_function+ calls. - def evaluate_remote_response - "eval(request.responseText)" - end - # Returns the JavaScript needed for a remote function. # Takes the same arguments as link_to_remote. # |