Fixes a strange issue where a <button> inside a nested <form> will trigger the event twice (1 for button, 1 for form)
This commit is contained in:
parent
a00cb9f556
commit
1c6d48ffa8
|
|
@ -57,17 +57,22 @@
|
|||
// ==============
|
||||
|
||||
$(document)
|
||||
.on('ajaxPromise', '[data-stripe-load-indicator]', function() {
|
||||
.on('ajaxPromise', '[data-stripe-load-indicator]', function(event) {
|
||||
// Prevent this event from bubbling up to a non-related data-request
|
||||
// element, for example a <form> tag wrapping a <button> tag
|
||||
event.stopPropagation()
|
||||
|
||||
$.oc.stripeLoadIndicator.show()
|
||||
|
||||
// This code will cover instances where the element has been removed
|
||||
// from the DOM, making the resolution event below an orphan.
|
||||
var $el = $(this);
|
||||
var $el = $(this)
|
||||
$(window).one('ajaxUpdateComplete', function(){
|
||||
if ($el.closest('html').length === 0)
|
||||
$.oc.stripeLoadIndicator.hide()
|
||||
})
|
||||
}).on('ajaxFail ajaxDone', '[data-stripe-load-indicator]', function() {
|
||||
}).on('ajaxFail ajaxDone', '[data-stripe-load-indicator]', function(event) {
|
||||
event.stopPropagation()
|
||||
$.oc.stripeLoadIndicator.hide()
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -65,17 +65,22 @@
|
|||
// ==============
|
||||
|
||||
$(document)
|
||||
.on('ajaxPromise', '[data-request]', function() {
|
||||
.on('ajaxPromise', '[data-request]', function(event) {
|
||||
// Prevent this event from bubbling up to a non-related data-request
|
||||
// element, for example a <form> tag wrapping a <button> tag
|
||||
event.stopPropagation()
|
||||
|
||||
$.oc.stripeLoadIndicator.show()
|
||||
|
||||
// This code will cover instances where the element has been removed
|
||||
// from the DOM, making the resolution event below an orphan.
|
||||
var $el = $(this);
|
||||
var $el = $(this)
|
||||
$(window).one('ajaxUpdateComplete', function(){
|
||||
if ($el.closest('html').length === 0)
|
||||
$.oc.stripeLoadIndicator.hide()
|
||||
})
|
||||
}).on('ajaxFail ajaxDone', '[data-request]', function() {
|
||||
}).on('ajaxFail ajaxDone', '[data-request]', function(event) {
|
||||
event.stopPropagation()
|
||||
$.oc.stripeLoadIndicator.hide()
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue