From 4c7132299734297bada063da0d22a0cba998d6a7 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sat, 21 Nov 2009 03:17:43 +0000 Subject: [PATCH] ENHANCEMENT Added form.clickedButton to all forms triggered inside LeftAndMain javascript git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92770 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/LeftAndMain.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/javascript/LeftAndMain.js b/javascript/LeftAndMain.js index be3ceb25..406f0b02 100644 --- a/javascript/LeftAndMain.js +++ b/javascript/LeftAndMain.js @@ -195,6 +195,9 @@ var ss_MainLayout; /** * @class Make all buttons "hoverable" with jQuery theming. + * Also sets the clicked button on a form submission, making it available through + * a new 'clickedButton' property on the form DOM element. + * * @name ss.LeftAndMain.Buttons */ $('.LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset').concrete('ss', function($){ @@ -217,6 +220,14 @@ var ss_MainLayout; }) .blur(function() { $(this).removeClass('ui-state-focus'); + }) + .click(function() { + var form = this.form; + // forms don't natively store the button they've been triggered with + form.clickedButton = this; + // Reset the clicked button shortly after the onsubmit handlers + // have fired on the form + setTimeout(function() {form.clickedButton = null;}, 10); }); this._super();