Skip to content

Instantly share code, notes, and snippets.

@brianjlandau
Created March 5, 2009 20:37
Show Gist options
  • Save brianjlandau/74544 to your computer and use it in GitHub Desktop.
Save brianjlandau/74544 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
$('.model-listing form.edit-comments').attach(Remote.Form, {
dataType: 'json',
success: function(json, status){
if (json.comment){
var parent_model = $(this.element[0]).parents('.model-listing');
parent_model.find('.model-comment').text(json.comment);
parent_model.find('.model-comment').show();
parent_model.find('form.edit-comments').hide();
parent_model.find('a.edit-comments').show();
} else {
alert('Your comment could not be saved.');
}
}
});
});
class SomeController < ApplicationController
def update
if @model.update_attributes(params[:comment])
render :json => {:comment => @job_sheet_listing.comment}
else
render :json => {:comment => false}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment