From 40990255c7f0945daf9b4f4576c32fc784f346c8 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Thu, 15 Apr 2010 19:53:18 +0000 Subject: [PATCH] Added some more Javascript behavior to edit version of custom forms. --- productMods/edit/forms/js/customForm.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/productMods/edit/forms/js/customForm.js b/productMods/edit/forms/js/customForm.js index 19984c23..f133d94b 100644 --- a/productMods/edit/forms/js/customForm.js +++ b/productMods/edit/forms/js/customForm.js @@ -256,6 +256,16 @@ var customForm = { case this.views.ADD_NEW: { fn = this.doEditFormAddNew; break; } default: { fn = this.doEditFormCombinedView; break; } } + + // Remember the original org. If we click the add new org link + // but then cancel out of it, we want to restore this value. + this.originalOrg = this.existingSelect.val(); + // But we only want to restore the original value from when the + // form loaded. If we've already changed to a new value, we don't + // want to restore that. + this.existingSelect.bind('change', function() { + customForm.originalOrg = null; + }); fn.call(customForm); }, @@ -357,6 +367,11 @@ var customForm = { customForm.button.val(customForm.defaultButtonText); customForm.doAddNewLinkForCombinedView(); customForm.setReturnView(customForm.views.COMBINED); + + if (customForm.originalOrg) { + customForm.existingSelect.val(customForm.originalOrg); + } + return false; }); },