-
-
Save victusfate/2303447 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$('.submittable').live('change', function() { | |
$(this).parents('form:first').submit(); | |
}); |
This file contains hidden or 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_for @thing, :remote => true do |f| %> | |
<%= f.check_box 'checked', :class => 'submittable' %> | |
<%= f.label :checked %> | |
<%= thing.name %> | |
<% end %> |
This file contains hidden or 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 ThingController < ApplicationController | |
def update | |
@thing = Thing.find params[:id] | |
@thing.update_attributes params[:thing] | |
end | |
end |
This file contains hidden or 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
// we could highlight the checkbox to show it's been clicked: | |
$('#thing').css("color","yellow"); | |
// or add the updated thing to a list: | |
$('#things').prepend('<%=escape_javascript render(@thing) %>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment