https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112721
Revision: 112721
Author: krinkle
Date: 2012-02-29 20:52:44 +0000 (Wed, 29 Feb 2012)
Log Message:
-----------
[ApiSandbox] Prevent duplicate submission of the form when clicking "Make
Request"
* The buttons had type=submit and were inside the <form> tree, when not
prevented the form is naturally submitted in a non-ajax fashion (which is then
hooked into from the submit handler)
* Fixes:
-- (bug 34790) [Regression] Pressing "Make Request" shouldn't make two requests
to api.php
* This commit is a re-do of r112702, which somehow freaked out SVN
Modified Paths:
--------------
trunk/extensions/ApiSandbox/ext.apiSandbox.js
Modified: trunk/extensions/ApiSandbox/ext.apiSandbox.js
===================================================================
--- trunk/extensions/ApiSandbox/ext.apiSandbox.js 2012-02-29 20:50:00 UTC
(rev 112720)
+++ trunk/extensions/ApiSandbox/ext.apiSandbox.js 2012-02-29 20:52:44 UTC
(rev 112721)
@@ -516,6 +516,10 @@
.appendTo( '#api-sandbox-parameters' )
.add( $submit )
.click( function ( e ) {
+ // Don't do default action (crawl up to <form>
and trigger a submit).
+ // That would submit it twice (bug 34790)
+ e.preventDefault();
+
$form.submit();
} )
.button({ disabled: true });
@@ -602,6 +606,9 @@
$form.submit( function ( e ) {
var url, params, mustBePosted;
+ // Prevent browser from submitting the form
+ // and reloading the page to the action-url.
+ // We're doing it with AJAX instead, below.
e.preventDefault();
if ( $submit.button( 'option', 'disabled' ) === true ) {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs