Use App.Comments module in create.js.erb

This commit is contained in:
kikito
2015-07-30 14:08:05 +02:00
parent 1237f9d8ad
commit 59cea45c26
2 changed files with 11 additions and 5 deletions

View File

@@ -1,6 +1,13 @@
App.Comments =
add_response: (parent_id, response_html) ->
$(response_html).insertAfter($("#js-comment-form-#{parent_id}"))
reset_and_hide_form: (id) ->
form = $("#js-comment-form-#{id}")
form.val('')
form.hide()
toggle_form: (id) ->
$("#js-comment-form-#{id}").toggle()

View File

@@ -1,4 +1,3 @@
var form = "#js-comment-form-<%= dom_id(@parent) %>"
$(form + " #comment_body").val('');
$(form).hide();
$("<%= j(render @comment) %>").insertAfter($(form));
var parent_id = '<%= dom_id(@parent) %>';
App.Comments.reset_and_hide_form(parent_id);
App.Comments.add_response(parent_id, "<%= j(render @comment) %>");