Adds "request-complete" to the data-attributes api

... I hope.
This commit is contained in:
Scott Bedard 2015-04-06 19:14:17 -04:00
parent 1236fa7f57
commit 7546174b35
1 changed files with 12 additions and 3 deletions

View File

@ -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(){ })
*/