validate only on focusOut or submit
This commit is contained in:
parent
f766e169bd
commit
2e742ea903
7 changed files with 39 additions and 8 deletions
|
@ -8,6 +8,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
|
||||||
submit: function(){
|
submit: function(){
|
||||||
this.validate();
|
this.validate();
|
||||||
|
|
||||||
|
$.each(Ember.View.views, function(id, view) {
|
||||||
|
if(view.isEasyForm) {
|
||||||
|
view.focusOut();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (this.get('isValid')) {
|
if (this.get('isValid')) {
|
||||||
this.send('save');
|
this.send('save');
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
|
||||||
submit: function(){
|
submit: function(){
|
||||||
this.validate();
|
this.validate();
|
||||||
|
|
||||||
|
$.each(Ember.View.views, function(id, view) {
|
||||||
|
if(view.isEasyForm) {
|
||||||
|
view.focusOut();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (this.get('isValid')) {
|
if (this.get('isValid')) {
|
||||||
this.send('save');
|
this.send('save');
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
|
||||||
submit: function(){
|
submit: function(){
|
||||||
this.validate();
|
this.validate();
|
||||||
|
|
||||||
|
$.each(Ember.View.views, function(id, view) {
|
||||||
|
if(view.isEasyForm) {
|
||||||
|
view.focusOut();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (this.get('isValid')) {
|
if (this.get('isValid')) {
|
||||||
// tricker save action
|
// tricker save action
|
||||||
this.send('save');
|
this.send('save');
|
||||||
|
|
|
@ -36,6 +36,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
|
||||||
submit: function() {
|
submit: function() {
|
||||||
this.validate();
|
this.validate();
|
||||||
|
|
||||||
|
$.each(Ember.View.views, function(id, view) {
|
||||||
|
if(view.isEasyForm) {
|
||||||
|
view.focusOut();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (this.get('isValid')) {
|
if (this.get('isValid')) {
|
||||||
// tricker save action
|
// tricker save action
|
||||||
this.send('save');
|
this.send('save');
|
||||||
|
|
|
@ -20,6 +20,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
|
||||||
submit: function() {
|
submit: function() {
|
||||||
this.validate();
|
this.validate();
|
||||||
|
|
||||||
|
$.each(Ember.View.views, function(id, view) {
|
||||||
|
if(view.isEasyForm) {
|
||||||
|
view.focusOut();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (this.get('isValid')) {
|
if (this.get('isValid')) {
|
||||||
// tricker save action
|
// tricker save action
|
||||||
this.send('save');
|
this.send('save');
|
||||||
|
|
|
@ -51,6 +51,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
|
||||||
submitNewUser: function() {
|
submitNewUser: function() {
|
||||||
this.validate();
|
this.validate();
|
||||||
|
|
||||||
|
$.each(Ember.View.views, function(id, view) {
|
||||||
|
if(view.isEasyForm) {
|
||||||
|
view.focusOut();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (this.get('isValid')) {
|
if (this.get('isValid')) {
|
||||||
// tricker save action
|
// tricker save action
|
||||||
this.send('addNewUser');
|
this.send('addNewUser');
|
||||||
|
|
|
@ -7,14 +7,7 @@ export default {
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
|
||||||
Ember.EasyForm.Input.reopen({
|
Ember.EasyForm.Input.reopen({
|
||||||
errorsChanged: function() {
|
|
||||||
this.set('hasFocusedOut', true);
|
|
||||||
this.showValidationError();
|
|
||||||
},
|
|
||||||
classNameBindings: ['wrapperConfig.inputClass', 'wrapperErrorClass'],
|
classNameBindings: ['wrapperConfig.inputClass', 'wrapperErrorClass'],
|
||||||
didInsertElement: function() {
|
|
||||||
this.addObserver('context.errors.' + this.property + '.@each', this, 'errorsChanged');
|
|
||||||
},
|
|
||||||
isCheckbox: function() {
|
isCheckbox: function() {
|
||||||
if (this.get('inputOptionsValues.as') === 'checkbox') {
|
if (this.get('inputOptionsValues.as') === 'checkbox') {
|
||||||
return true;
|
return true;
|
||||||
|
@ -30,7 +23,9 @@ export default {
|
||||||
else {
|
else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}.property('inputOptionsValues')
|
}.property('inputOptionsValues'),
|
||||||
|
|
||||||
|
isEasyForm: true
|
||||||
});
|
});
|
||||||
|
|
||||||
Ember.EasyForm.Error.reopen({
|
Ember.EasyForm.Error.reopen({
|
||||||
|
|
Loading…
Reference in a new issue