r112721 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112720‎ | r112721 | r112722 >
Date:20:52, 29 February 2012
Author:krinkle
Status:ok
Tags:
Comment:
[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) (history)

Diff [purge]

Index: trunk/extensions/ApiSandbox/ext.apiSandbox.js
@@ -516,6 +516,10 @@
517517 .appendTo( '#api-sandbox-parameters' )
518518 .add( $submit )
519519 .click( function ( e ) {
 520+ // Don't do default action (crawl up to <form> and trigger a submit).
 521+ // That would submit it twice (bug 34790)
 522+ e.preventDefault();
 523+
520524 $form.submit();
521525 } )
522526 .button({ disabled: true });
@@ -602,6 +606,9 @@
603607 $form.submit( function ( e ) {
604608 var url, params, mustBePosted;
605609
 610+ // Prevent browser from submitting the form
 611+ // and reloading the page to the action-url.
 612+ // We're doing it with AJAX instead, below.
606613 e.preventDefault();
607614
608615 if ( $submit.button( 'option', 'disabled' ) === true ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r112723MFT to 1.19wmf1 r112721...hashar20:56, 29 February 2012
r112734[ApiSandbox] Remove redundant click-handler...krinkle22:19, 29 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109726[ApiSandbox] front-end makeover...krinkle07:10, 22 January 2012
r112702[ApiSandbox] Prevent duplicate submission of the form when clicking "Make Req...krinkle18:03, 29 February 2012

Status & tagging log