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
This commit is contained in:
Ingo Schommer 2009-11-21 03:17:43 +00:00
parent 650d44dd57
commit 4c71322997

View File

@ -195,6 +195,9 @@ var ss_MainLayout;
/** /**
* @class Make all buttons "hoverable" with jQuery theming. * @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 * @name ss.LeftAndMain.Buttons
*/ */
$('.LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset').concrete('ss', function($){ $('.LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset').concrete('ss', function($){
@ -217,6 +220,14 @@ var ss_MainLayout;
}) })
.blur(function() { .blur(function() {
$(this).removeClass('ui-state-focus'); $(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(); this._super();