added render of the answerbox to the response

This commit is contained in:
nilsding 2015-01-03 18:56:06 +01:00
parent e37907f948
commit 88b71d8f31
3 changed files with 6 additions and 1 deletions

View File

@ -18,6 +18,7 @@ $(document).on "click", "button#q-answer", ->
$.ajax
url: '/ajax/answer'
type: 'POST'
dataType: 'json'
data:
id: qid
answer: $("textarea#q-answer[data-id=#{qid}]").val()
@ -26,6 +27,8 @@ $(document).on "click", "button#q-answer", ->
success: (data, status, jqxhr) ->
if data.success
$("div#q-answer-box").slideUp()
# TODO:
# ($ "div#q-answer-box").prepend data.render
showNotification data.message, data.success
error: (jqxhr, status, error) ->
console.log jqxhr, status, error

View File

@ -41,6 +41,7 @@ class Ajax::AnswerController < ApplicationController
@status = :okay
@message = "Successfully answered question."
@success = true
@render = render_to_string(partial: 'shared/answerbox', locals: { a: answer, show_question: false }) unless inbox
end
def destroy

View File

@ -1 +1,2 @@
json.partial! 'ajax/shared/status'
json.partial! 'ajax/shared/status'
json.render @render if @render