Topic: Rails 3 + ajax partial send data (:with or :submit removed)

since the rails version 3, and the refactoring of the javascript integration (Unobtrusive JavaScript) and also of the helper method link_to_remote => link_to(url, :remote => true)

It seems the parameters :submit and :with have been removed. So it not possible anymore to send data like the old way

<div id="remote_message" style="display:none"></div>

<div id="create_input">
  <label>Movie name</label>
  <input type="text" name="create_movie_name" id="create_movie_name" value="" />

<%= link_to_remote "Create movie", 
  {:url=>'/movie/create',  :submit=>"create_input",  
    :failure=>'handleCreateFailure(request);' }, 
  {:id=>'create_movie_link_id'} %>

read this article for more details … _to_remote
or … _to_remote

I try with the new helper link_to (in remote mode) to send data with the old attributes (:submit and :with)

I would like to achieve this in rails 3 WAY. Do you have any idea ???

PS: I can t believe the rails team remove this feature without replace it !!!
PS: There is no gem/plugin release ? Maybe i shoud create one smile

Thks for your future replies

Re: Rails 3 + ajax partial send data (:with or :submit removed)

I can't believe they would of dropped the ball on this??????

There's got to be something in 3.0 release notes!

I have to upgrade soon,  I'll report back if I find anything then.

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Rails 3 + ajax partial send data (:with or :submit removed)

Thanks man.

I finally found a solution by reading this post, and i m still pretty sure they don t provide a way to submit a partial dom by ajax. … -attribute

But it only works with the GET ajax request call sad, but the solution is pretty clean, and doesn't break anything (it respect the html5 attributes data-*), but you need the query

<div id="myform">
  First name: <input type="text" name="fname" id="fname" /><br />
  Last name: <input type="text" name="lname" id="lname" /><br />

<%= link_to "Foo", {:action => "filter", :filter => "filter1"}, {:remote => true, :method =>:get , "data-submit" => "#myform input"} %>


PS: data-with can contains multiple selectors "data-with" => "#myform input,#myform select" if you have a html select in your div

The code above is run with Jquery.

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {


       $(this).bind('click', function() {
          var href= $(this).attr('href');
         var url = href.split('?')[0];
          var data =  $(this).attr('data-submit');
          var params = $(data).serialize();

          $(this).attr(url +'?'+params );



Any idea how to achieve this with a ajax POST request ?

Or somebody could point me in the rails source code (version 2.3.x) how they achieve this features with (link_to_remote => :with or :submit)

Last edited by regis.leray (2010-12-23 06:14:15)