From f921df10450913cf12ad2f0697243a409a5ff0d3 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 22 Jun 2013 17:54:07 +0200 Subject: [PATCH] Re-enabled global ajax error messages. --- app/assets/javascripts/app/lib/app_post/ajax.js.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/ajax.js.coffee b/app/assets/javascripts/app/lib/app_post/ajax.js.coffee index b844ed714..6161b1685 100644 --- a/app/assets/javascripts/app/lib/app_post/ajax.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/ajax.js.coffee @@ -2,11 +2,11 @@ class App.Com _instance = undefined # Must be declared here to force the closure on the class @ajax: (args) -> # Must be a static method if _instance == undefined - _instance ?= new _Singleton + _instance ?= new _ajaxSingleton _instance.ajax(args) # The actual Singleton class -class _Singleton +class _ajaxSingleton defaults: contentType: 'application/json' dataType: 'json' @@ -33,7 +33,7 @@ class _Singleton ) # show error messages - $('body').bind( 'ajaxError', ( e, jqxhr, settings, exception ) -> + $(document).bind( 'ajaxError', ( e, jqxhr, settings, exception ) -> status = jqxhr.status detail = jqxhr.responseText if !status && !detail @@ -45,6 +45,9 @@ class _Singleton # do not show any error message on wrong login return if status is 422 + # do not show any error message with code 200 + return if status is 200 + # show human readable message if status is 401 status = 'Access denied.'