Skip to content

Instantly share code, notes, and snippets.

@originalpete
Last active December 16, 2015 14:49
Show Gist options
  • Save originalpete/5451373 to your computer and use it in GitHub Desktop.
Save originalpete/5451373 to your computer and use it in GitHub Desktop.
Railsgirls javascript submit
jQuery(document).ready(function() {
$('.update-done :checkbox').on('change', function () {
var checkbox = $(this);
var form = checkbox.parent('form');
$.ajax(form.attr('action'), {type: 'PUT', data: form.serialize()});
});
});
<td class="update-done">
<%= form_for idea , :url => update_done_idea_path(idea), :method=>"put" do |f| %>
<%= f.check_box :done %>
<% end %>
</td>
resources :ideas do
put :update_done, :on => :member
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment