generating questions is great

This commit is contained in:
nilsding 2014-12-09 23:37:44 +01:00
parent 912ccea445
commit a4edb4147d
2 changed files with 20 additions and 2 deletions

View File

@ -1,3 +1,19 @@
($ document).on "click", "button#ib-generate-question", ->
btn = ($ this)
btn.button "loading"
$.ajax
url: '/ajax/generate_question'
type: 'POST'
dataType: 'json'
success: (data, status, jqxhr) ->
if data.success
($ "div#entries").prepend(data.render) # TODO: slideDown or something
error: (jqxhr, status, error) ->
console.log jqxhr, status, error
showNotification "An error occurred, a developer should check the console for details", false
complete: (jqxhr, status) ->
btn.button "reset"
$(document).on "keydown", "textarea[name=ib-answer]", (evt) ->
iid = $(this)[0].dataset.id
if evt.keyCode == 13 and evt.ctrlKey

View File

@ -1,12 +1,14 @@
.container.j2-page
= render 'layouts/messages'
%button.btn.btn-default{type: :button, id: 'ib-generate-question'} Get new question
#entries
- @inbox.each do |i|
= render 'inbox/entry', i: i
- if @inbox.empty?
- if @inbox.empty?
Nothing to see here.
Nothing to see here.
= render "shared/links"
- @inbox.update_all(new: false)