mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Fix loading button with invalid form (#20754)
Previously, if a invalid form was submitted (for example issue with no title), the form could not be re-submitted again because the button would not stay stuck in loading state. Fix that by hooking the 'submit' event instead which triggers only when the form is valid. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		| @@ -142,16 +142,12 @@ export function initGlobalCommon() { | |||||||
|     } |     } | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   // loading-button this logic used to prevent push one form more than one time |   // prevent multiple form submissions on forms containing .loading-button | ||||||
|   $(document).on('click', '.button.loading-button', function (e) { |   document.addEventListener('submit', (e) => { | ||||||
|     const $btn = $(this); |     const btn = e.target.querySelector('.loading-button'); | ||||||
|  |     if (!btn) return; | ||||||
|     if ($btn.hasClass('loading')) { |     if (btn.classList.contains('loading')) return e.preventDefault(); | ||||||
|       e.preventDefault(); |     btn.classList.add('loading'); | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     $btn.addClass('loading disabled'); |  | ||||||
|   }); |   }); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user