From 45ec03500c16f1dd4552ef3c9cfcadd1674073e1 Mon Sep 17 00:00:00 2001 From: JediKev <kevin@enhancesoft.com> Date: Wed, 24 Oct 2018 09:44:33 -0500 Subject: [PATCH] issue: Dupe Page Requests Fix This addresses an issue with pull 4472 where disabling the Submit button does not submit the Input value for the button. This affects the installation of plugins, where the Install Path is not sent therefore the plugin is not installed. This clones the original submit button, hides it, then displays a dummy disabled Submit button which will submit the value and prevent dupe posts. --- js/osticket.js | 10 +++++++++- scp/js/scp.js | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/js/osticket.js b/js/osticket.js index c88c925b8..95589f582 100644 --- a/js/osticket.js +++ b/js/osticket.js @@ -47,7 +47,15 @@ $(document).ready(function(){ $(window).unbind('beforeunload'); // Disable client-side Post Reply/Create Ticket buttons to help // prevent duplicate POST - $(':submit', $(this)).attr('disabled', true); + var form = $(this); + $(this).find('input[type="submit"]').each(function (index) { + // Clone original input + $(this).clone(false).removeAttr('id').prop('disabled', true).insertBefore($(this)); + + // Hide original input and add it to top of form + $(this).hide(); + form.prepend($(this)); + }); $('#overlay, #loading').show(); return true; }); diff --git a/scp/js/scp.js b/scp/js/scp.js index c6e6f3c87..177c0a529 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -165,7 +165,15 @@ var scp_prep = function() { $(window).unbind('beforeunload'); // Disable staff-side Post Reply/Open buttons to help prevent // duplicate POST - $(':submit', $(this)).attr('disabled', true); + var form = $(this); + $(this).find('input[type="submit"]').each(function (index) { + // Clone original input + $(this).clone(false).removeAttr('id').prop('disabled', true).insertBefore($(this)); + + // Hide original input and add it to top of form + $(this).hide(); + form.prepend($(this)); + }); $('#overlay, #loading').show(); return true; }); -- GitLab