From fddb38589de3aa554a34a7fde9be924ee948b865 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Fri, 12 Apr 2013 00:03:24 -0400 Subject: [PATCH] Store and reinstate valid state/county when copying --- templates/CRM/common/stateCountry.tpl | 30 +++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/templates/CRM/common/stateCountry.tpl b/templates/CRM/common/stateCountry.tpl index 54ad3bfe47..3cbe1558c5 100644 --- a/templates/CRM/common/stateCountry.tpl +++ b/templates/CRM/common/stateCountry.tpl @@ -43,7 +43,21 @@ callbackURL = {/literal}"{crmURL p='civicrm/ajax/jqState' h=0}"{literal} - cj( '#' + countryID ).chainSelect( '#' + stateProvinceID, callbackURL, null ); + cj( '#' + countryID ).chainSelect( + '#' + stateProvinceID, + callbackURL, + { + before : function (target) { + if (typeof(setdefault) === "undefined") { setdefault = new Array(); } + targetid = cj(target).attr("id"); + eval('setdefault[targetid] = cj(target).val()'); + }, + after : function(target) { + targetid = cj(target).attr("id"); + cj(target).val(setdefault[targetid]); + } + } + ); }); {/literal} {/if} @@ -63,7 +77,19 @@ callbackURL = {/literal}"{crmURL p='civicrm/ajax/jqCounty' h=0}"{literal} - cj( '#' + stateProvinceID ).chainSelect( '#' + countyID, callbackURL, null ); + cj( '#' + stateProvinceID ).chainSelect( '#' + countyID, callbackURL, + { + before : function (target) { + if (typeof(setdefault) === "undefined") { setdefault = new Array(); } + targetid = cj(target).attr("id"); + eval('setdefault[targetid] = cj(target).val()'); + }, + after : function(target) { + targetid = cj(target).attr("id"); + cj(target).val(setdefault[targetid]); + } + } + ); }); {/literal} {/if} -- 2.25.1