Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #CommentsController
- def edit
- @comment = Comment.find(params[:id])
- @comment.body = params[:value]
- @comment.save
- render :text => params.to_json
- end
- #Comment View
- <p class="comment_body" id="comment_<%= comment.id %>" name="comment_body"><%= comment.body %></p>
- <input type="hidden" class="comment_edit_path" value="<%= edit_setup_comment_path(@setup, comment) %>" />
- #edit_setup_comment_path echoes out "/setups/44/comments/19/edit"
- #and finally, the JS
- $(comment_body).editable(edit_path, {
- submitdata: {
- comment_id: comment_id
- },
- method: "put",
- indicator: 'Saving...',
- tooltip: 'Click to edit...',
- type: 'textarea',
- cancel: 'Cancel',
- submit: 'Save',
- onblur: 'ignore',
- width: '495px'
- });
Add Comment
Please, Sign In to add comment