added disable attribute if there are no questions in the inbox

This commit is contained in:
nilsding 2014-12-21 14:11:35 +01:00
parent 1ba34c59d0
commit 7a18790241
2 changed files with 5 additions and 2 deletions

View File

@ -19,22 +19,25 @@
if confirm 'Are you sure?' if confirm 'Are you sure?'
btn = ($ this) btn = ($ this)
btn.button "loading" btn.button "loading"
succ = no
$.ajax $.ajax
url: '/ajax/delete_all_inbox' url: '/ajax/delete_all_inbox'
type: 'POST' type: 'POST'
dataType: 'json' dataType: 'json'
success: (data, status, jqxhr) -> success: (data, status, jqxhr) ->
if data.success if data.success
succ = yes
entries = ($ "div#entries") entries = ($ "div#entries")
entries.slideUp 400, -> entries.slideUp 400, ->
entries.html("Nothing to see here.") entries.html("Nothing to see here.")
entries.fadeIn() entries.fadeIn()
btn.attr("disabled", "disabled")
error: (jqxhr, status, error) -> error: (jqxhr, status, error) ->
console.log jqxhr, status, error console.log jqxhr, status, error
showNotification "An error occurred, a developer should check the console for details", false showNotification "An error occurred, a developer should check the console for details", false
complete: (jqxhr, status) -> complete: (jqxhr, status) ->
btn.button "reset" btn.button "reset"
if succ
btn.attr "disabled", "disabled" # this doesn't really work like I wanted it to…
$(document).on "keydown", "textarea[name=ib-answer]", (evt) -> $(document).on "keydown", "textarea[name=ib-answer]", (evt) ->

View File

@ -10,7 +10,7 @@
.panel-heading .panel-heading
%h3 Actions %h3 Actions
.panel-body .panel-body
%button.btn.btn-block.btn-danger{type: :button, id: 'ib-delete-all'} Delete all questions %button.btn.btn-block.btn-danger{type: :button, id: 'ib-delete-all', disabled: (@inbox.empty? ? 'disabled' : nil)} Delete all questions
.col-md-9.col-xs-12.col-sm-9 .col-md-9.col-xs-12.col-sm-9
= render 'layouts/messages' = render 'layouts/messages'
#entries #entries