Guest User

Untitled

a guest
Jul 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #CommentsController
  2.  
  3. def edit
  4.  
  5. @comment = Comment.find(params[:id])
  6. @comment.body = params[:value]
  7. @comment.save
  8.  
  9. render :text => params.to_json
  10.  
  11. end
  12.  
  13. #Comment View
  14.  
  15. <p class="comment_body" id="comment_<%= comment.id %>" name="comment_body"><%= comment.body %></p>
  16. <input type="hidden" class="comment_edit_path" value="<%= edit_setup_comment_path(@setup, comment) %>" />
  17.  
  18. #edit_setup_comment_path echoes out "/setups/44/comments/19/edit"
  19.  
  20. #and finally, the JS
  21.  
  22. $(comment_body).editable(edit_path, {
  23. submitdata: {
  24. comment_id: comment_id
  25. },
  26. method: "put",
  27. indicator: 'Saving...',
  28. tooltip: 'Click to edit...',
  29. type: 'textarea',
  30. cancel: 'Cancel',
  31. submit: 'Save',
  32. onblur: 'ignore',
  33. width: '495px'
  34. });
Add Comment
Please, Sign In to add comment