I think I'll feel stupid once I see the answer, but I can't wrap my head around why or
is working but and
isn't on this ComputedProperty
. The tutorial suggested I'd need to use and
, but I can't figure out how I'd do that if this doesn't work.
To start with I am new to Ember and familiar but not really comfortable with javascript, which is why I assume I'm having difficulty understanding what is going on here.
I have two properties that I need to both be true
before a button isDisabled
. I pass each of them to their own properties that reverse their boolean state so isDisabled
remains active on a button until the original properties are both flipped.
contact.js
emailAddress: '',
message: '',
//**original properties**
isValid: Ember.computed.match('emailAddress', /^.+@.+\..+$/),//starts as false
validMessage: Ember.computed.gte('message.length', 5),//starts as false
//**my reversing boolean properties**
notYet: Ember.computed.not('isValid'),//starts as true
notNow: Ember.computed.not('validMessage'),//starts as true
//isDisabled must be true to be active disabling button
isDisabled: Ember.computed.or('notYet', 'notNow'),//starts as true
If I put in the correct emailAddress format:
emailAddress = true
notYet = false
isDisabled = true //still
If I then put a validMessage of 5 characters or more
validMessage = true
notNow = false
isDisabled = false //now
Why does "or" work for this, why doesn't "and" or "not"?
Aucun commentaire:
Enregistrer un commentaire