From 4d7101b631eef62577c179c3a423c20696d59d2a Mon Sep 17 00:00:00 2001 From: Eric Ryan Jones Date: Sun, 14 Jul 2013 15:12:12 -0400 Subject: [PATCH] SOC-5 #comment JS code was in wrong place and form had the wrong class name. --- app/assets/javascripts/comments.js.coffee | 25 +++-------------------- app/assets/javascripts/topics.js.coffee | 23 ++++++++++++++++++++- app/views/comments/_form.html.erb | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee index 93bc865..7615679 100644 --- a/app/assets/javascripts/comments.js.coffee +++ b/app/assets/javascripts/comments.js.coffee @@ -1,22 +1,3 @@ -# comments.js.coffee -jQuery -> - # Create a comment - $(".comment-form") - .on "ajax:beforeSend", (evt, xhr, settings) -> - $(this).find('textarea') - .addClass('uneditable-input') - .attr('disabled', 'disabled'); - .on "ajax:success", (evt, data, status, xhr) -> - $(this).find('textarea') - .removeClass('uneditable-input') - .removeAttr('disabled', 'disabled') - .val(''); - $(xhr.responseText).hide().insertAfter($(this)).show('slow') - # Delete a comment - $(document) - .on "ajax:beforeSend", ".comment", -> - $(this).fadeTo('fast', 0.5) - .on "ajax:success", ".comment", -> - $(this).hide('fast') - .on "ajax:error", ".comment", -> - $(this).fadeTo('fast', 1) \ No newline at end of file +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/topics.js.coffee b/app/assets/javascripts/topics.js.coffee index 2a5d841..7ba0146 100644 --- a/app/assets/javascripts/topics.js.coffee +++ b/app/assets/javascripts/topics.js.coffee @@ -1,3 +1,24 @@ # Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ \ No newline at end of file +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ +jQuery -> + # Create a comment + $(".comment-form") + .on "ajax:beforeSend", (evt, xhr, settings) -> + $(this).find('textarea') + .addClass('uneditable-input') + .attr('disabled', 'disabled'); + .on "ajax:success", (evt, data, status, xhr) -> + $(this).find('textarea') + .removeClass('uneditable-input') + .removeAttr('disabled', 'disabled') + .val(''); + $(xhr.responseText).hide().insertAfter($(this)).show('slow') + # Delete a comment + $(document) + .on "ajax:beforeSend", ".comment", -> + $(this).fadeTo('fast', 0.5) + .on "ajax:success", ".comment", -> + $(this).hide('fast') + .on "ajax:error", ".comment", -> + $(this).fadeTo('fast', 1) \ No newline at end of file diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 1dcc04d..f597aad 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -1,4 +1,4 @@ -
+
<%= simple_form_for comment, :remote => true do |f| %> <%= f.input :body, :input_html => { :rows => "2" }, :label => false %> <%= f.input :commentable_id, :as => :hidden, :value => comment.commentable_id %>