From e880da0d0e85783eb373f2a6d703311a681c5609 Mon Sep 17 00:00:00 2001 From: abastardi Date: Wed, 23 Aug 2017 11:43:40 -0400 Subject: [PATCH] Fix submit button disable bug When a form includes more than one submit button, after being disabled all buttons are re-enabled with the value of the first button rather than having their original values restored. This change iterates over each button separately to disable and enable. --- applications/welcome/static/js/web2py.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/applications/welcome/static/js/web2py.js b/applications/welcome/static/js/web2py.js index 1b52245e..f59263f1 100644 --- a/applications/welcome/static/js/web2py.js +++ b/applications/welcome/static/js/web2py.js @@ -265,13 +265,17 @@ } }); /* help preventing double form submission for normal form (not LOADed) */ - $(doc).on('submit', 'form', function () { - var submit_button = $(this).find(web2py.formInputClickSelector); - web2py.disableElement(submit_button); + $(doc).on('submit', 'form', function (e) { + var submit_buttons = $(this).find(web2py.formInputClickSelector); + submit_buttons.each(function() { + web2py.disableElement($(this)); + }) /* safeguard in case the form doesn't trigger a refresh, see https://github.com/web2py/web2py/issues/1100 */ setTimeout(function () { - web2py.enableElement(submit_button); + submit_buttons.each(function() { + web2py.enableElement($(this)); + }); }, 5000); }); doc.ajaxSuccess(function (e, xhr) {