Skip to content

Commit

Permalink
Merge pull request #187 from brandonparsons/observer-timing-issues
Browse files Browse the repository at this point in the history
Observer timing issues
  • Loading branch information
mike-north committed Jul 26, 2015
2 parents 97e51a5 + a97bfc5 commit 823e01a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions addon/components/md-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ export default MaterializeInputField.extend({
errorsDidChange: Ember.observer('errors', function() {
var inputSelector = this.$('input');
// monitor the select's validity and copy the appropriate validation class to the materialize input element.
Ember.run.later(this, function() {
var isValid = this.$('select').hasClass('valid');
if (isValid) {
inputSelector.removeClass('invalid');
inputSelector.addClass('valid');
} else {
inputSelector.removeClass('valid');
inputSelector.addClass('invalid');
}
}, 150);
if (!Ember.isNone(inputSelector)) {
Ember.run.later(this, function() {
var isValid = this.$('select').hasClass('valid');
if (isValid) {
inputSelector.removeClass('invalid');
inputSelector.addClass('valid');
} else {
inputSelector.removeClass('valid');
inputSelector.addClass('invalid');
}
}, 150);
}
})
});

0 comments on commit 823e01a

Please sign in to comment.