From 06474b83b13d01dd60d0b55d2f889da669390a11 Mon Sep 17 00:00:00 2001 From: lonalore Date: Fri, 11 Aug 2017 09:28:49 +0200 Subject: [PATCH] Fix for issue #2762 --- e107_web/js/core/all.jquery.js | 83 +++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/e107_web/js/core/all.jquery.js b/e107_web/js/core/all.jquery.js index cd8179c33..061635c4a 100644 --- a/e107_web/js/core/all.jquery.js +++ b/e107_web/js/core/all.jquery.js @@ -331,6 +331,52 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}}; } }; + /** + * Behavior to initialize submit buttons. + * + * @type {{attach: e107.behaviors.buttonSubmit.attach}} + */ + e107.behaviors.buttonSubmit = { + attach: function (context, settings) + { + $(context).find('button[type=submit]').once('button-submit').each(function () + { + $(this).on('click', function () + { + var $button = $(this); + var $form = $button.closest('form'); + + var type = $button.data('loading-icon'); + + if(type === undefined || $form.length === 0) + { + return true; + } + + $form.submit(function () + { + if ($form.find('.has-error').length > 0) { + return false; + } + + var caption = ""; + caption += "" + $button.text() + ""; + + $button.html(caption); + + if($button.attr('data-disable') == 'true') + { + $button.addClass('disabled'); + } + }); + + return true; + } + ); + }); + } + }; + /** * Check if the selector is valid. * @@ -851,42 +897,7 @@ $(document).ready(function() $(id).hide("slow"); return false; - }); - - - - $('button[type=submit]').on('click', function() - { - var caption = $(this).text(); - var type = $(this).attr('data-loading-icon'); - var formid = $(this).closest('form').attr('id'); - var but = $(this); - - if(type === undefined || (formid === undefined)) - { - return true; - } - - $('#'+formid).submit(function(){ // only animate on successful submission. - - caption = "" + caption + ""; - - $(but).html(caption); - - if( $(but).attr('data-disable') == 'true') - { - - $(but).addClass('disabled'); - } - - }); - - - return true; - } - ); - - + }); // Dates --------------------------------------------------