From f3af44fab0b5d59f33e2aebfd75f06a2fd230589 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Tue, 10 Jan 2017 14:46:09 +0000 Subject: [PATCH] add on-success and on-error handlers to async-form. --- services/web/public/coffee/directives/asyncForm.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/web/public/coffee/directives/asyncForm.coffee b/services/web/public/coffee/directives/asyncForm.coffee index 2c6345d878..b3e13e8d61 100644 --- a/services/web/public/coffee/directives/asyncForm.coffee +++ b/services/web/public/coffee/directives/asyncForm.coffee @@ -33,6 +33,10 @@ define [ response.success = true response.error = false + if onSuccessHandler = scope[attrs.onSuccess] + onSuccessHandler(data, status, headers, config) + return + if data.redir? ga('send', 'event', formName, 'success') window.location = data.redir @@ -50,6 +54,11 @@ define [ scope[attrs.name].inflight = false response.success = false response.error = true + + if onErrorHandler = scope[attrs.onError] + onErrorHandler(data, status, headers, config) + return + if status == 403 # Forbidden response.message = text: "Session error. Please check you have cookies enabled. If the problem persists, try clearing your cache and cookies."