Store and reinstate valid state/county when copying
authorAndrew Hunt <andrew@aghstrategies.com>
Fri, 12 Apr 2013 04:03:24 +0000 (00:03 -0400)
committerAndrew Hunt <andrew@aghstrategies.com>
Fri, 12 Apr 2013 04:03:24 +0000 (00:03 -0400)
templates/CRM/common/stateCountry.tpl

index 54ad3bfe472e3379b193fbfc2780b791e2865016..3cbe1558c50f2640263ded133e837e5092b021fa 100644 (file)
 
         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}
 
         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}