Add the ability to override the confirm function
This commit is contained in:
parent
3d903191ee
commit
986b3a95a8
|
|
@ -32,11 +32,31 @@ if (window.jQuery === undefined)
|
|||
var isUnloading = false
|
||||
$(window).on('beforeunload', function() { isUnloading = true })
|
||||
|
||||
/*
|
||||
* Custom function, requests confirmation from the user
|
||||
*/
|
||||
|
||||
function handleConfirmMessage(message) {
|
||||
var _event = jQuery.Event('ajaxConfirmMessage')
|
||||
|
||||
_event.promise = $.Deferred()
|
||||
if ($(window).triggerHandler(_event, [message]) !== undefined) {
|
||||
_event.promise.done(function(){
|
||||
options.confirm = null
|
||||
new Request(element, handler, options)
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (_event.isDefaultPrevented()) return
|
||||
if (message) return confirm(message)
|
||||
}
|
||||
|
||||
/*
|
||||
* Initiate request
|
||||
*/
|
||||
|
||||
if (options.confirm !== undefined && options.confirm.length && !confirm(options.confirm))
|
||||
if (options.confirm && !handleConfirmMessage(options.confirm))
|
||||
return
|
||||
|
||||
var
|
||||
|
|
|
|||
Loading…
Reference in New Issue