validate only on focusOut or submit

This commit is contained in:
jelhan 2014-10-26 18:19:07 +01:00
parent f766e169bd
commit 2e742ea903
7 changed files with 39 additions and 8 deletions

View file

@ -8,6 +8,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
submit: function(){
this.validate();
$.each(Ember.View.views, function(id, view) {
if(view.isEasyForm) {
view.focusOut();
}
});
if (this.get('isValid')) {
this.send('save');
}

View file

@ -8,6 +8,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
submit: function(){
this.validate();
$.each(Ember.View.views, function(id, view) {
if(view.isEasyForm) {
view.focusOut();
}
});
if (this.get('isValid')) {
this.send('save');
}

View file

@ -88,6 +88,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
submit: function(){
this.validate();
$.each(Ember.View.views, function(id, view) {
if(view.isEasyForm) {
view.focusOut();
}
});
if (this.get('isValid')) {
// tricker save action
this.send('save');

View file

@ -36,6 +36,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
submit: function() {
this.validate();
$.each(Ember.View.views, function(id, view) {
if(view.isEasyForm) {
view.focusOut();
}
});
if (this.get('isValid')) {
// tricker save action
this.send('save');

View file

@ -20,6 +20,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
submit: function() {
this.validate();
$.each(Ember.View.views, function(id, view) {
if(view.isEasyForm) {
view.focusOut();
}
});
if (this.get('isValid')) {
// tricker save action
this.send('save');

View file

@ -50,6 +50,12 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
submitNewUser: function() {
this.validate();
$.each(Ember.View.views, function(id, view) {
if(view.isEasyForm) {
view.focusOut();
}
});
if (this.get('isValid')) {
// tricker save action

View file

@ -7,14 +7,7 @@ export default {
initialize: function() {
Ember.EasyForm.Input.reopen({
errorsChanged: function() {
this.set('hasFocusedOut', true);
this.showValidationError();
},
classNameBindings: ['wrapperConfig.inputClass', 'wrapperErrorClass'],
didInsertElement: function() {
this.addObserver('context.errors.' + this.property + '.@each', this, 'errorsChanged');
},
isCheckbox: function() {
if (this.get('inputOptionsValues.as') === 'checkbox') {
return true;
@ -30,7 +23,9 @@ export default {
else {
return '';
}
}.property('inputOptionsValues')
}.property('inputOptionsValues'),
isEasyForm: true
});
Ember.EasyForm.Error.reopen({