From 7a2f6dae10214ac0d4c54f79c9b8432ec4ec2406 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Fri, 6 May 2011 15:29:33 -0700 Subject: [PATCH] fixed js error on new comments on statusmessage show page --- app/controllers/comments_controller.rb | 13 +------------ app/views/comments/create.js.erb | 5 +++++ public/javascripts/stream.js | 4 ---- 3 files changed, 6 insertions(+), 16 deletions(-) create mode 100644 app/views/comments/create.js.erb diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 18e0e7277..a8ef1c8b6 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -21,18 +21,7 @@ class CommentsController < ApplicationController Postzord::Dispatch.new(current_user, @comment).post respond_to do |format| - format.js{ - json = { :post_id => @comment.post_id, - :comment_id => @comment.id, - :html => render_to_string( - :partial => 'comments/comment', - :locals => { :comment => @comment, - :person => current_user.person, - } - ) - } - render(:json => json, :status => 201) - } + format.js{ render(:create, :status => 201)} format.html{ render :nothing => true, :status => 201 } format.mobile{ redirect_to @comment.post } end diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb new file mode 100644 index 000000000..bc4bba110 --- /dev/null +++ b/app/views/comments/create.js.erb @@ -0,0 +1,5 @@ +WebSocketReceiver.processComment(<%= @comment.post_id %>, + <%= @comment.id %>, + "<%= escape_javascript(render(:partial => 'comments/comment', :locals => { :comment => @comment, :person => current_user.person}))%>", + false); + diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js index 646365a91..f48f4d198 100644 --- a/public/javascripts/stream.js +++ b/public/javascripts/stream.js @@ -89,10 +89,6 @@ var Stream = { } }); - $(stream_string + " .new_comment").live('ajax:success', function(data, json, xhr) { - json = $.parseJSON(json); - WebSocketReceiver.processComment(json.post_id, json.comment_id, json.html, false); - }); $(stream_string + ".new_comment").live('ajax:failure', function(data, html, xhr) { Diaspora.widgets.alert.alert('Failed to post message!'); });