Created
March 5, 2009 20:37
-
-
Save brianjlandau/74544 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
$(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.'); | |
} | |
} | |
}); | |
}); |
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 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