frontend/js/components/form.js in trestle-0.9.2 vs frontend/js/components/form.js in trestle-0.9.3

- old
+ new

@@ -20,18 +20,24 @@ init(function (root) { const $form = $(root).find(FORM_SELECTOR) $form .on('ajax:send', function (e) { + // Only run when triggered directly on form + if (e.target !== this) return + // Disable submit buttons $(this).find(':submit').prop('disabled', true) // Set loading status on button that triggered submission const button = $(this).data('trestle:submitButton') if (button) { $(button).addClass('loading') } }) .on('ajax:complete', function (e) { + // Only run when triggered directly on form + if (e.target !== this) return + const xhr = e.detail[0] // Reset submit buttons $(this).find(':submit').prop('disabled', false).removeClass('loading') $(this).removeData('trestle:submitButton') @@ -62,9 +68,12 @@ const title = `${xhr.status} (${xhr.statusText})` showError(title, xhr.responseText) } }) .on('ajax:success', function (e) { + // Only run when triggered directly on form + if (e.target !== this) return + const xhr = e.detail[2] const $context = $(this).closest('[data-context]') let location = xhr.getResponseHeader('X-Trestle-Location')