NIHVIVO-1110 Fix cancel button after validation errors on all custom form types

This commit is contained in:
rjy7 2010-09-03 21:50:27 +00:00
parent 6f2dcba70d
commit 2a2d87006b

View file

@ -159,15 +159,6 @@ var customForm = {
this.showAutocompleteSelection(label, uri);
}
this.cancel.unbind('click');
this.cancel.click(function() {
// Cancel back to full view with only type selection showing
customForm.undoAutocompleteSelection();
customForm.clearFields(customForm.fullViewOnly);
customForm.initFormFullView();
return false;
});
},
// Bind event listeners that persist over the life of the page. Event listeners
@ -178,13 +169,7 @@ var customForm = {
var typeVal = $(this).val();
// If an autocomplete selection has been made, undo it.
// The test is not just for efficiency: undoAutocompleteSelection empties the acSelector value,
// which we don't want to do if user has manually entered a value, since he may intend to
// change the type but keep the value. If no new value has been selected, form initialization
// below will correctly empty the value anyway.
if (!customForm.acSelection.is(':hidden')) {
customForm.undoAutocompleteSelection();
}
customForm.undoAutocompleteSelection();
// Reinitialize view. If no type selection in a two-step form, go back to type view;
// otherwise, reinitialize full view.
@ -357,17 +342,22 @@ var customForm = {
// selection (from showAutocomplete) before returning to full view.
undoAutocompleteSelection: function() {
this.acSelectorWrapper.show();
this.hideFields(this.acSelection);
this.acSelector.val('');
this.acUriReceiver.val('');
this.acSelectionInfo.html('');
this.verifyMatch.attr('href', this.verifyMatch.data('baseHref'));
// The test is not just for efficiency: undoAutocompleteSelection empties the acSelector value,
// which we don't want to do if user has manually entered a value, since he may intend to
// change the type but keep the value. If no new value has been selected, form initialization
// below will correctly empty the value anyway.
if (!this.acSelection.is(':hidden')) {
this.acSelectorWrapper.show();
this.hideFields(this.acSelection);
this.acSelector.val('');
this.acUriReceiver.val('');
this.acSelectionInfo.html('');
this.verifyMatch.attr('href', this.verifyMatch.data('baseHref'));
if (this.formSteps > 1) {
this.acSelection.find('label').html('Selected ');
if (this.formSteps > 1) {
this.acSelection.find('label').html('Selected ');
}
}
},
// Set type uri for autocomplete, and type name for labels and button text.