Commit ff1fccbd

mo khan <mo@mokhan.ca>
2014-07-05 15:52:12
move comment posting to the disqus backbone view.
1 parent 402fdbb
Changed files (1)
app
assets
javascripts
app/assets/javascripts/backbone/views/disqus_view.js.coffee
@@ -10,12 +10,14 @@ class CakeSide.Views.DisqusView extends Backbone.View
   render: (options) ->
     try
       @$el.removeClass('hidden')
+      that = @
       DISQUS.reset
         reload: true,
         config: ->
           @page.identifier = options.identifier
           @page.title = "CakeSide - #{options.title}"
           @page.url = options.url
+          @callbacks.onNewComment = [that.saveComment]
       @
     catch error
       console.log(error)
@@ -24,3 +26,7 @@ class CakeSide.Views.DisqusView extends Backbone.View
 
   hide: ->
     @$el.addClass('hidden')
+
+  saveComment: (comment) ->
+    $.post Routes.comments_path(), { id: comment.id, url: document.URL, comment: comment }, (result) ->
+      console.log(result)