NIHVIVO-646 Move custom form utilities to a separate js file and add utility mixin methods to mix them in to specific custom forms. Make paths to css and js files in formPrefix.jsp and formSuffix.jsp absolute instead of relative.
This commit is contained in:
parent
ba418660e3
commit
7e1d4186ad
4 changed files with 72 additions and 10 deletions
27
webapp/web/js/customFormUtils.js
Normal file
27
webapp/web/js/customFormUtils.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
var vitro;
|
||||
if (!vitro) {
|
||||
vitro = {};
|
||||
}
|
||||
|
||||
vitro.customFormUtils = {
|
||||
|
||||
// This method should always be called instead of calling hide() directly on any
|
||||
// element containing form fields.
|
||||
hideFields: function(el) {
|
||||
// Clear any input and error message, so if we re-show the element it won't still be there.
|
||||
this.clearFields(el);
|
||||
el.hide();
|
||||
},
|
||||
|
||||
// Clear data from form elements in element el
|
||||
clearFields: function(el) {
|
||||
el.find(':input[type!="hidden"][type!="submit"][type!="button"]').val('');
|
||||
|
||||
// For now we can remove the error elements. Later we may include them in
|
||||
// the markup, for customized positioning, in which case we will empty them
|
||||
// but not remove them here. See findValidationErrors().
|
||||
el.find('.validationError').remove();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue