There are two things I can see at fault here:
Firstly, you have added some extra indirection to your bindings in the view, which I believe is causing problems. You've created a computed property called strengthUpdater
that has a side effect of setting the _passwordScore
property. Most likely barClass
is not seeing that _passwordScore
has been updated due to some run loop magic.
_passwordScore: 0,
strengthUpdater: function() {
// ...
this.set('_passwordScore', strength); // code smell
return strength;
}.property('password'),
It is usually not a good idea to change other properties inside a computed property function. Instead, if you need both _passwordScore
and strengthUpdater
properties to be the same value, use Ember.computed.alias
.
This can be simplified to a single computed property:
_passwordScore: function() {
var calc = function(pw) {
return ( Math.random() * 4 + 1 );
};
return calc(this.get('password'));
}.property('password'),
strengthUpdater: Ember.computed.alias('_passwordScore') // if you still need it
I tried this in a jsBin here and this fixed the most significant part of your issue.
Secondly, the class names are not being applied correctly:
div.strength-bar class=view.barClass
This becomes:
<div class="strength-bar" {{bind-attr class="view.barClass"}}></div>
As you can see, you are declaring a class attribute and then creating a binding on the same attribute. In my testing, the strength-bar
class is being overwritten and only score-x
is applied. You'll want this:
<div {{bind-attr class=":strength-bar view.barClass"}}></div>
Sorry, I am not sure how Emblem would achieve this syntax.