From 7546174b357d2572c129ad45a3951b64479237cf Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Mon, 6 Apr 2015 19:14:17 -0400 Subject: [PATCH] Adds "request-complete" to the data-attributes api ... I hope. --- modules/system/assets/js/framework.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/system/assets/js/framework.js b/modules/system/assets/js/framework.js index 664bcbf0c..a81704032 100644 --- a/modules/system/assets/js/framework.js +++ b/modules/system/assets/js/framework.js @@ -166,6 +166,12 @@ if (window.jQuery === undefined) return updatePromise }, + complete: function(data, textStatus, jqXHR) { + + form.trigger('ajaxComplete', [context, data, textStatus, jqXHR]) + options.evalComplete && eval('(function($el, context, data, textStatus, jqXHR) {'+options.evalComplete+'}($el, context, data, textStatus, jqXHR))') + + }, /* * Custom function, display an error message to the user @@ -189,7 +195,7 @@ if (window.jQuery === undefined) var updatePromise = $.Deferred().done(function(){ for (var partial in data) { /* - * If a partial has been supplied on the client side that matches the server supplied key, look up + * If a partial has been supplied on the client side that matches the server supplied key, look up * it's selector and use that. If not, we assume it is an explicit selector reference. */ var selector = (options.update[partial]) ? options.update[partial] : partial @@ -262,6 +268,7 @@ if (window.jQuery === undefined) */ context.success = requestOptions.success context.error = requestOptions.error + context.complete = requestOptions.complete requestOptions = $.extend(requestOptions, options) requestOptions.data = data.join('&') @@ -294,7 +301,8 @@ if (window.jQuery === undefined) beforeUpdate: function(data, textStatus, jqXHR) {}, evalBeforeUpdate: null, evalSuccess: null, - evalError: null + evalError: null, + evalComplete: null, } /* @@ -322,6 +330,7 @@ if (window.jQuery === undefined) evalBeforeUpdate: $this.data('request-before-update'), evalSuccess: $this.data('request-success'), evalError: $this.data('request-error'), + evalComplete: $this.data('request-complete'), confirm: $this.data('request-confirm'), redirect: $this.data('request-redirect'), loading: $this.data('request-loading'), @@ -411,7 +420,7 @@ if (window.jQuery === undefined) /* * Invent our own event that unifies document.ready with window.ajaxUpdateComplete - * + * * $(document).render(function() { }) * $(document).on('render', function(){ }) */