NIHVIVO-3825 fields now retain values after validation error

This commit is contained in:
tworrall 2012-06-26 21:19:28 +00:00
parent f739b86766
commit 4d187cfe67
2 changed files with 14 additions and 7 deletions

View file

@ -7,7 +7,7 @@ var mailingAddressUtils = {
this.bindEventListeners();
this.sortCountrySelector(mode,country);
if ( mode == "add" ) {
if ( mode == "add" && !this.errorSection.attr('id') ) {
this.containerDiv.hide();
this.submitButton.hide();
}
@ -35,7 +35,7 @@ var mailingAddressUtils = {
this.submitButton = $('#submit');
this.containerDiv = $('#addressDetails');
this.orSpan = $('span.or');
this.errorSection = $('section#error-alert');
},
bindEventListeners: function() {
@ -118,7 +118,14 @@ var mailingAddressUtils = {
// if it's add mode, add the "select one" option have it be selected;
// if it's edit mode, add the "Select one" option but have the correct country selected.
// if it's repair mode, add the "Select one" option but only select it if there's no country
if ( mode == "add" ) {
if ( this.errorSection.is(':visible') ) {
this.countrySelector.prepend($("<option></option>")
.attr("value","")
.text("Select one"));
this.countrySelector.val(country);
}
else if ( mode == "add" ) {
this.countrySelector.prepend($("<option selected></option>")
.attr("value","")
.text("Select one"));
@ -136,5 +143,4 @@ var mailingAddressUtils = {
this.countrySelector.val(country);
}
}
}

View file

@ -79,9 +79,10 @@
<label for="country" style="margin-bottom:-4px">Country ${requiredHint}</label>
<#assign countryOpts = editConfiguration.pageData.country />
<select id="country" name="country" >
<#list countryOpts?keys as key>
<option value="${countryOpts[key]?uncap_first?replace("the ", "")?cap_first}" >
${countryOpts[key]?uncap_first?replace("the ", "")?cap_first}
<#list countryOpts?keys as key>
<#assign countryName = countryOpts[key]?uncap_first?replace("the ", "")?cap_first >
<option value="${countryName}" <#if countryName == countryValue>selected</#if>>
${countryName}
</option>
</#list>
</select>