Merge remote-tracking branch 'origin/master'

This commit is contained in:
Andreas N 2015-01-03 18:57:39 +01:00
commit e22dd08f75
3 changed files with 6 additions and 1 deletions

View File

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

View File

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

View File

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