Last active
August 29, 2015 14:01
-
-
Save alecguintu/769754f640bdfa0b9d3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('ul.links').on 'ajax:success', '.link', (evt, data, status, xhr) -> | |
console.log 'link clicked' | |
console.log $(this) | |
$('#this-form').bind 'ajax:success', (evt, data, status, xhr) -> | |
console.log 'form submitted' | |
# # When .link is clicked | |
# link clicked | |
# [a.link ...] | |
# form submitted | |
# # When form submitted | |
# form submitted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TheController < Dashboard::ApplicationController | |
... | |
def update | |
... | |
respond_to do |format| | |
format.html { redirect_to :back } | |
format.json { render json: { success: true } } | |
end | |
end | |
def update_all | |
... | |
respond_to do |format| | |
format.html { redirect_to :back } | |
format.json { render json: { success: true } } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag update_all_objects_path, id: 'this-form', method: :patch, remote: true, data: {type: :json} %> | |
<ul> | |
<% @objects.each do |object| %> | |
<%= link_to 'Update', object_path(object), class: 'link', method: :patch, remote: true, data: {type: :json} %> | |
<% end %> | |
</ul> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment