--- !ruby/object:RI::MethodDescription 
aliases: []

block_params: 
comment: 
- !ruby/struct:SM::Flow::P 
  body: Returns a link to a remote action defined by <tt>options[:url]</tt> (using the url_for format) that's called in the background using XMLHttpRequest. The result of that request can then be inserted into a DOM object whose id can be specified with <tt>options[:update]</tt>. Usually, the result would be a partial prepared by the controller with render :partial.
- !ruby/struct:SM::Flow::P 
  body: "Examples:"
- !ruby/struct:SM::Flow::VERB 
  body: "  # Generates: &lt;a href=&quot;#&quot; onclick=&quot;new Ajax.Updater('posts', '/blog/destroy/3', {asynchronous:true, evalScripts:true});\n  #            return false;&quot;&gt;Delete this post&lt;/a&gt;\n  link_to_remote &quot;Delete this post&quot;, :update =&gt; &quot;posts&quot;,\n    :url =&gt; { :action =&gt; &quot;destroy&quot;, :id =&gt; post.id }\n\n  # Generates: &lt;a href=&quot;#&quot; onclick=&quot;new Ajax.Updater('emails', '/mail/list_emails', {asynchronous:true, evalScripts:true});\n  #            return false;&quot;&gt;&lt;img alt=&quot;Refresh&quot; src=&quot;/images/refresh.png?&quot; /&gt;&lt;/a&gt;\n  link_to_remote(image_tag(&quot;refresh&quot;), :update =&gt; &quot;emails&quot;,\n    :url =&gt; { :action =&gt; &quot;list_emails&quot; })\n"
- !ruby/struct:SM::Flow::P 
  body: You can override the generated HTML options by specifying a hash in <tt>options[:html]</tt>.
- !ruby/struct:SM::Flow::VERB 
  body: "  link_to_remote &quot;Delete this post&quot;, :update =&gt; &quot;posts&quot;,\n    :url  =&gt; post_url(@post), :method =&gt; :delete,\n    :html =&gt; { :class  =&gt; &quot;destructive&quot; }\n"
- !ruby/struct:SM::Flow::P 
  body: "You can also specify a hash for <tt>options[:update]</tt> to allow for easy redirection of output to an other DOM element if a server-side error occurs:"
- !ruby/struct:SM::Flow::P 
  body: "Example:"
- !ruby/struct:SM::Flow::VERB 
  body: "  # Generates: &lt;a href=&quot;#&quot; onclick=&quot;new Ajax.Updater({success:'posts',failure:'error'}, '/blog/destroy/5',\n  #            {asynchronous:true, evalScripts:true}); return false;&quot;&gt;Delete this post&lt;/a&gt;\n  link_to_remote &quot;Delete this post&quot;,\n    :url =&gt; { :action =&gt; &quot;destroy&quot;, :id =&gt; post.id },\n    :update =&gt; { :success =&gt; &quot;posts&quot;, :failure =&gt; &quot;error&quot; }\n"
- !ruby/struct:SM::Flow::P 
  body: Optionally, you can use the <tt>options[:position]</tt> parameter to influence how the target DOM element is updated. It must be one of <tt>:before</tt>, <tt>:top</tt>, <tt>:bottom</tt>, or <tt>:after</tt>.
- !ruby/struct:SM::Flow::P 
  body: The method used is by default POST. You can also specify GET or you can simulate PUT or DELETE over POST. All specified with <tt>options[:method]</tt>
- !ruby/struct:SM::Flow::P 
  body: "Example:"
- !ruby/struct:SM::Flow::VERB 
  body: "  # Generates: &lt;a href=&quot;#&quot; onclick=&quot;new Ajax.Request('/person/4', {asynchronous:true, evalScripts:true, method:'delete'});\n  #            return false;&quot;&gt;Destroy&lt;/a&gt;\n  link_to_remote &quot;Destroy&quot;, :url =&gt; person_url(:id =&gt; person), :method =&gt; :delete\n"
- !ruby/struct:SM::Flow::P 
  body: By default, these remote requests are processed asynchronous during which various JavaScript callbacks can be triggered (for progress indicators and the likes). All callbacks get access to the <tt>request</tt> object, which holds the underlying XMLHttpRequest.
- !ruby/struct:SM::Flow::P 
  body: To access the server response, use <tt>request.responseText</tt>, to find out the HTTP status, use <tt>request.status</tt>.
- !ruby/struct:SM::Flow::P 
  body: "Example:"
- !ruby/struct:SM::Flow::VERB 
  body: "  # Generates: &lt;a href=&quot;#&quot; onclick=&quot;new Ajax.Request('/words/undo?n=33', {asynchronous:true, evalScripts:true,\n  #            onComplete:function(request){undoRequestCompleted(request)}}); return false;&quot;&gt;hello&lt;/a&gt;\n  word = 'hello'\n  link_to_remote word,\n    :url =&gt; { :action =&gt; &quot;undo&quot;, :n =&gt; word_counter },\n    :complete =&gt; &quot;undoRequestCompleted(request)&quot;\n"
- !ruby/struct:SM::Flow::P 
  body: "The callbacks that may be specified are (in order):"
- !ruby/object:SM::Flow::LIST 
  contents: 
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:loading</tt>:"
    body: Called when the remote document is being loaded with data by the browser.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:loaded</tt>:"
    body: Called when the browser has finished loading the remote document.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:interactive</tt>:"
    body: Called when the user can interact with the remote document, even though it has not finished loading.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:success</tt>:"
    body: Called when the XMLHttpRequest is completed, and the HTTP status code is in the 2XX range.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:failure</tt>:"
    body: Called when the XMLHttpRequest is completed, and the HTTP status code is not in the 2XX range.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:complete</tt>:"
    body: Called when the XMLHttpRequest is complete (fires after success/failure if they are present).
  type: :NOTE
- !ruby/struct:SM::Flow::P 
  body: You can further refine <tt>:success</tt> and <tt>:failure</tt> by adding additional callbacks for specific status codes.
- !ruby/struct:SM::Flow::P 
  body: "Example:"
- !ruby/struct:SM::Flow::VERB 
  body: "  # Generates: &lt;a href=&quot;#&quot; onclick=&quot;new Ajax.Request('/testing/action', {asynchronous:true, evalScripts:true,\n  #            on404:function(request){alert('Not found...? Wrong URL...?')},\n  #            onFailure:function(request){alert('HTTP Error ' + request.status + '!')}}); return false;&quot;&gt;hello&lt;/a&gt;\n  link_to_remote word,\n    :url =&gt; { :action =&gt; &quot;action&quot; },\n    404 =&gt; &quot;alert('Not found...? Wrong URL...?')&quot;,\n    :failure =&gt; &quot;alert('HTTP Error ' + request.status + '!')&quot;\n"
- !ruby/struct:SM::Flow::P 
  body: A status code callback overrides the success/failure handlers if present.
- !ruby/struct:SM::Flow::P 
  body: If you for some reason or another need synchronous processing (that'll block the browser while the request is happening), you can specify <tt>options[:type] = :synchronous</tt>.
- !ruby/struct:SM::Flow::P 
  body: "You can customize further browser side call logic by passing in JavaScript code snippets via some optional parameters. In their order of use these are:"
- !ruby/object:SM::Flow::LIST 
  contents: 
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:confirm</tt>:"
    body: Adds confirmation dialog.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:condition</tt>:"
    body: Perform remote request conditionally by this expression. Use this to describe browser-side conditions when request should not be initiated.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:before</tt>:"
    body: Called before request is initiated.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:after</tt>:"
    body: Called immediately after request was initiated and before <tt>:loading</tt>.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:submit</tt>:"
    body: 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.
  - !ruby/struct:SM::Flow::LI 
    label: "<tt>:with</tt>:"
    body: A JavaScript expression specifying the parameters for the XMLHttpRequest. Any expressions should return a valid URL query string.
  - !ruby/struct:SM::Flow::P 
    body: "Example:"
  - !ruby/struct:SM::Flow::VERB 
    body: "  :with =&gt; &quot;'name=' + $('name').value&quot;\n"
  type: :NOTE
- !ruby/struct:SM::Flow::P 
  body: You can generate a link that uses AJAX in the general case, while degrading gracefully to plain link behavior in the absence of JavaScript by setting <tt>html_options[:href]</tt> to an alternate URL. Note the extra curly braces around the <tt>options</tt> hash separate it as the second parameter from <tt>html_options</tt>, the third.
- !ruby/struct:SM::Flow::P 
  body: "Example:"
- !ruby/struct:SM::Flow::VERB 
  body: "  link_to_remote &quot;Delete this post&quot;,\n    { :update =&gt; &quot;posts&quot;, :url =&gt; { :action =&gt; &quot;destroy&quot;, :id =&gt; post.id } },\n    :href =&gt; url_for(:action =&gt; &quot;destroy&quot;, :id =&gt; post.id)\n"
full_name: ActionView::Helpers::PrototypeHelper#link_to_remote
is_singleton: false
name: link_to_remote
params: (name, options = {}, html_options = nil)
visibility: public
