From 802f4bfd6bfcad186e1702534c8fe97b74a192e2 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 6 Mar 2018 16:25:54 -0600 Subject: [PATCH] Add `disable_submit_button()` global JS function managed to find another use for this, so split it out --- tailbone/static/js/tailbone.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tailbone/static/js/tailbone.js b/tailbone/static/js/tailbone.js index 67f9a409..5de153fc 100644 --- a/tailbone/static/js/tailbone.js +++ b/tailbone/static/js/tailbone.js @@ -40,6 +40,20 @@ function disable_button(button, label) { } +function disable_submit_button(form, label) { + // for some reason chrome requires us to do things this way... + // https://stackoverflow.com/questions/16867080/onclick-javascript-stops-form-submit-in-chrome + // https://stackoverflow.com/questions/5691054/disable-submit-button-on-form-submit + var submit = $(form).find('input[type="submit"]'); + if (! submit.length) { + submit = $(form).find('button[type="submit"]'); + } + if (submit.length) { + disable_button(submit, label); + } +} + + /* * Load next / previous page of results to grid. This function is called on * the click event from the pager links, via inline script code. @@ -208,18 +222,7 @@ $(function() { $('a.button.autodisable').click(function() { disable_button(this); }); - // for some reason chrome requires us to do things this way... - // https://stackoverflow.com/questions/16867080/onclick-javascript-stops-form-submit-in-chrome - // https://stackoverflow.com/questions/5691054/disable-submit-button-on-form-submit - $('form.autodisable').submit(function() { - var submit = $(this).find('input[type="submit"]'); - if (! submit.length) { - submit = $(this).find('button[type="submit"]'); - } - if (submit.length) { - disable_button(submit); - } - }); + $('form.autodisable').submit(disable_submit_button); /* * enhance dropdowns