diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 18e0e727778c2f39f4b6901a85852f3cf8a8dabb..a8ef1c8b6097be625bac820294da54573ba9c4f1 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 0000000000000000000000000000000000000000..bc4bba1100156a1b9c53754df18bcc644ee67ccb --- /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 646365a91b6ac99e0681955969564da96da1c05d..f48f4d1980ec367a9dabfe2379cf558aa6d283d6 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!'); });