From a97bfc58e5b17a265492371f0daade71b5a6d570 Mon Sep 17 00:00:00 2001 From: Brandon Parsons Date: Wed, 22 Jul 2015 06:45:43 -0600 Subject: [PATCH] Observer was causing timing issues - check for presence of element before using it. --- addon/components/md-select.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/addon/components/md-select.js b/addon/components/md-select.js index 6894c06c..d86555ca 100644 --- a/addon/components/md-select.js +++ b/addon/components/md-select.js @@ -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); + } }) });