window formComponentUI flight component function this defaultAttrs err

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
window.formComponentUI = flight.component(
function() {
this.defaultAttrs({
errorFieldSelector: '.js-field-error'
});
this.showErrors = function(formErrors) {
var that = this;
for (var name in formErrors) {
that.$node.find('.js-' + name + '-error').html(formErrors[name]);
}
};
this.hideErrors = function() {
this.select('errorFieldSelector').empty();
};
this.after('initialize', function() {
this.on('submit-done', this.hideErrors);
this.on('submit-form', this.hideErrors);
this.on('submit-error', function(e, v){
this.showErrors(v);
});
});
});